icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » Private Hosting » SSH Commands: Current Count 48

Private Hosting Questions about VPS, dedicated servers and colocation.

Reply
 
LinkBack Thread Tools Search this Thread
Old August 26th, 2004, 6:39 PM   #1 (permalink)
Searcher
Surpass Staff
 
Kayla's Avatar
 
Joined in May 2003
Lives in Orlando
24,448 posts
Gave thanks: 935
Thanked 783 times
SSH Commands: Current Count 48

Please reply with your most often used commands. Please number them if you can so we can keep track with how many we have here.

Here are some to start:

1. How to block an IP an via SSH?
/sbin/iptables -I INPUT -s 222.222.222.2 -j DROP

2. How to stop apache via SSH (if a website has high traffic and causing server load to rise)?
service httpd stop

3. How to start apache via SSH?
service httpd restart

4. How to start the POP mailserver?
/usr/local/cpanel/bin/cppop

5. How to restart Named (DNS server)
service named restart

6. w
Show who is currently connected to your server via SSH and what they are currently doing.

7. top
Show the top processes in terms of how much processor time/memory, etc. they are using in real time. Don't run this for a long time, because it can put a strain on an already overworked server.

8. How do I see all the files in a directory?
ls

List directory. ls -a to view a list of files including the "hidden" files that start with a "." ls -l list files with more information like owner, group and permissions info. You can combine both like this ls -la or ls -al

9. less <filename>
To view a file a page at a time.

10. pico -w <filename>
to edit a file

11. rm -r <directory name>
to recursively remove a directory (use with caution

12. ps -ewf | grep <search string>
to find a running process matching <search string>

13. tail <filename>
to view the end of a file - useful for example if you want to monitor a log file. As the file is updates, the new contect will be displayed on screen.
Probably not a good idea to run for too long.....

14. How do I change directories?
Type: cd <directory name> (Move to another directory)
Type: cd .. (Move back a directory)

15. How do I check permissions on a file?
Type: ls -l (Will show permissions for all files in directory)

16. How do I check disk space?
Type: df -m (Will show all free space info for all drives)

17. How do I check all running services?
Type: ps -xa

18. How do I view the contents of a text file?
Type: cat <filename>

19. How do I debug a cgi script?
Goto the directory the file is in.
Type: ./filename.cgi
Read outputs, and fix errors based on output read.

20. How do I execute a program, but send it to the background?
Execute the command normally but add an & at the end of it.

21. How do I bring a program back from the background?
Type: fg

22. How do I know what my CPU Information is?
Type: cat /proc/cpuinfo

23. How do I know what my memory information is? RAM
Type: cat /proc/meminfo

24. How do I find out information about my hard drives?
Type: fdisk -l

25. I just uploaded/moved some files to a customers/user of mine and now they can't modify/rename/delete this file?
This is because you uploaded the file as a different user/root.
Login to your server via SSH & Type: /scripts/chownpublichtmls

26. Sometimes when moving an account to your WHM Account from another
WHM Account/server you will get an error where the domain is forbidden.
Login to your server via SSH & Type: /scripts/enablefileprotect

27. How can I view the status of my Advanced Policy Firewall ? (APF)
Login to your server via SSH & Type: /etc/apf/apf -st

28. How can I stop my Advanced Policy Firewall ? (APF)
Login to your server via SSH & Type: service apf stop

29. How can I start my Advanced Policy Firewall ? (APF)
Login to your server via SSH & Type: service apf start

30. How can I restart CPanel via SSH?
Login to your server via SSH & Type: /etc/rc.d/init.d/cpanel restart

31. How can I stop BIND / NAMED from SSH?
Login to your server via SSH & Type: /etc/init.d/named stop

32. How can I start BIND / NAMED from SSH?
Login to your server via SSH & Type: /etc/init.d/named start

33. How can I force AWSTATS to update?
Login to your server via SSH & Type: /scripts/runlogsnow

34. How can I find files owned by a customer/user?
Login to your server via SSH & Type: find -user username *Replace username*
Kayla is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 26th, 2004, 7:03 PM   #2 (permalink)
I admire kayla
On a golden path...
 
Joined in Aug 2003
Lives in Saint Petersburg, Florida
Hosted on VPS5
478 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
35. How Do I locate a file?
whereis <filename>
36. How Do I Copy?
cp Copy a file.
cp -i Copy a file and ask before overwriting.
cp -r Copy a directory with its contents.
37. Move/Renaming?
mv Move or rename a file.
mv -i Move or rename a file and ask before overwriting.
38. Remove?
rm -rf /* (dont really do /* because It will remove everything!)
rm Remove a file.
rm -r Remove a directory with its contents.
rm -i Ask before removing a file. Good to use with the -r option.
39. Make and Remove?
mkdir Make a directory.
rmdir Remove an empty directory
40. PWD
pwd "Print working directory" - show what dir you're in.
41. LS
ls List the contents of a dir.
ls -l List the contents of a dir and show additional info of the files.
ls -a List all files, including hidden files.
42. CD
cd Change directory.
cd .. Go to the parent directory.
43. Cat
Cat is a simple little program that displays the contents of a text file when you give the file name as an argument to it:
$ cat view_this
less is a program that lets you view text files, like cat does, but if the files are so long that they don't fit on your screen, less automatically paginates the file. You use less by giving the file name as an argument to it:
$ less view_this
You can also open several files at the same time so you can navigate from one file to next without closing it first. If you want to open several files, just give all the file names at once:
$ less file1 file2 file3
When viewing several files at the same time, you can use :n for examining the next file and :P for the previous file.

Here are some, but absolutely not all, of the commands you can use in less:
Command / key Action
e, j, Down, or Enter - move forward one line
y, k, or Up - move backward one line
f, Space, or Page - Down move forward one page
b, or Page Up - move backward one page
/characters - search forward in the file for lines containing the specified characters
n - repeat the previous search
:e file_name - examine a new file
:n - examine the next file
:P - examine the previous file
h, or ? - display help
q - quit
44. Off the subject lil bit:
Planning account creation

You should make sure to provide user accounts with only the minimal requirements for the task they need to do. If you provide your secretary, or another general user, with an account, you might want them to only have access to a word processor or drawing program, but be unable to delete data that is not his or hers.

Several good rules of thumb when allowing other people legitimate access to your Linux machine:

* Limit access privileges given to new users.
* Be aware when/where they login from, or should be logging in from.
* Make sure to remove inactive accounts
* The use of the same user-ID on all computers and networks is advisable to ease account maintenance, as well as permit easier analysis of log data (but I'm sure someone will dispute this). However, it's practically essential if using NFS. There are several other protocols that use UIDs for local and remote access as well.
* The creation of group user-IDs should be absolutely prohibited. User accounts also provide accountability, and this is not possible with group accounts.
* Be sure shadow passwords are enabled. Shadow passwords is a method for storing the actual user's password in a root-owned file that is not readable by normal users, unlike the regular password file. This protects the passwords from being read and cracked using dictionary attacks. Most (if not all) current distributions already use shadow passwords.
* Regularly audit user accounts for invalid or unused accounts, expired accounts, etc.
* Check for repeated login failures. The files in /var/log are invaluable resource to track potential security problems.
* Be sure to enable quotas on machines with many users, to prevent denial of service attacks involving filling disk partitions, or appending exploits to group-writable files.
* Disable group accounts, and unused system accounts, such as sys or uucp. These accounts should be locked, and given non-functional shells.
* Many local user accounts that are used in security compromises are ones that have not been used in months or years. Since no one is using them they provide the ideal attack vehicle.

Back on:
45. Permissions
chmod <permission> <file>

Last edited by Unleashed2k; August 26th, 2004 at 7:06 PM.
Unleashed2k is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old August 26th, 2004, 7:15 PM   #3 (permalink)
I admire kayla
On a golden path...
 
Joined in Aug 2003
Lives in Saint Petersburg, Florida
Hosted on VPS5
478 posts
Gave thanks: 1
Thanked 1 Time in 1 Post
46. Copy (A Guide)
$ cp file file2


The following does the same as the above, but if file2 exists, you'll be prompted before overwriting:
$ cp -i file file2
cp: overwrite `file2'? n
$

So it's a good idea to use the -i option whenever you're dealing with important files you don't want to lose!

If you want to copy file into directory dir1:
$ cp file dir1

The following would do the same as the above, copy file into dir1, but under a different name:
$ cp file dir1/file2

You can also copy multiple files into one directory with a single command:
$ cp file1 file2 file3 dir1

Note that if the last argument isn't a directory name, you'll get an error message complaining about it.

47. Moving and RENAMING (A Guide)

The mv command can be used for moving or renaming files. To rename a file, you can use it like this:
$ mv file file2

If file2 doesn't exist, it'll be created, but if it exists, it'll be overwritten. If you want to be prompted before overwriting files, you can use the -i option the same way as with cp:

$ mv -i file file2
mv: overwrite `file2'? y
$

To move the file into another directory:
$ mv file dir1

If you want to rename the file to file2 and move it into another directory, you probably already figured out the command:
$ mv file dir1/file2

48. Renaming Files (A GUIDE)

The rm command is used for removing files and directories. To remove a file:
$ rm file

If you use the -i option, you'll be prompted before removing the file:
$ rm -i file

You can also delete more files at once:
rm file1 file2

Be careful with the rm command! As I already told you, Linux doesn't have any undo commands, and it doesn't put files into Trash where you can save them later. Once you've deleted a file, it's bye-bye!
Unleashed2k is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On