It appears you have not registered with our community. To register please click here ...

Author Topic: Commonly Used Shell Commands  (Read 4084 times)

dynaweb

  • <b>Canine Deamon</b>
  • Administrator
  • Sr. Member
  • *****
  • Posts: 493
  • Karma: +10/-0
  • Generic personal text here ...
    • MSN Messenger - danno_d_manno@yahoo.com
    • View Profile
    • DynaWeb Designs
    • Email
Commonly Used Shell Commands
« on: August 01, 2005, 07:49:58 PM »
..:: Common SSH Commands or Linux Shell Commands ::..
 
These are some basic linux commands I most commonly use when administering my linux shell. I work a lot remotely, so I use Putty or some secure SSH client. From a Linux desktop, you could use X-Terminal.
 
 


[indent]// wall : broadcasts a server wide message
Code: [Select]
wall "hi"
// ls : list files/directories in a directory, comparable to dir in windows/dos.
: shows all files (including ones that start with a period), directories, and details attributes for each file.
Code: [Select]
ls -al
// df : shows filesystem and usage
Code: [Select]
df
// cd : change directory · ·
: go to /usr/local/apache/ directory
Code: [Select]
cd /usr/local/apache: go to your home directory
Code: [Select]
cd ~: go to the last directory you were in
Code: [Select]
cd -
: go up a directory cat : print file contents to the screen
Code: [Select]
cd ..
// cat filename.txt : cat the contents of filename.txt to your screen
Code: [Select]
cat filename.txt
// tail : like cat, but only reads the end of the file
: see the last 20 (by default) lines of /var/log/messages
Code: [Select]
tail /var/log/messages
: watch the file continuously, while it\'s being updated
Code: [Select]
tail -f /var/log/messages: print the last 200 lines of the file to the screen
Code: [Select]
tail -200 /var/log/messages
// more : like cat, but opens the file one screen at a time rather than all at once
: browse through the userdomains file. hit to go to the next page, to quit
Code: [Select]
more /etc/userdomains
 
// pico : friendly, easy to use file editor
: edit the index page for the user\'s website.
Code: [Select]
pico /home/common/public_html/index.html(Your system may have "nano" which is a pico clone. In that case just replace "pico" with "nano" in the examples.)
 
// vi : another editor, tons of features, harder to use at first than pico
: edit the index page for the user\'s website.
Code: [Select]
vi /home/common/public_html/index.html
 
// grep : looks for patterns in files
: shows all matches of root in /etc/p***wd
Code: [Select]
grep root /etc/p***wd: shows all lines that do not match root
Code: [Select]
grep -v root /etc/p***wd
 
// touch : creates an empty file
: create an empty file called 404.html in the directory /home/common/public_html/
Code: [Select]
touch /home/common/public_html/404.html
// ln : create\'s "links" between files and directories
Code: [Select]
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf : Now you can edit /etc/httpd.conf rather than the original. changes will affect the orginal, however you can delete the link and it will not delete the original.
 
// rm : delete a file
: deletes filename.txt, will more than likely ask if you really want to delete it
Code: [Select]
rm filename.txt: deletes filename.txt, will not ask for confirmation before deleting.
Code: [Select]
rm -f filename.txt: recursively deletes the directory tmp, and all files in it, including subdirectories.
Code: [Select]
rm -Rf tmp/ BE VERY CAREFULL WITH THIS COMMAND!!!
 
// last : shows who logged in and when
: shows only the last 20 logins
Code: [Select]
last -20: shows last 20 logins, with the hostname in the last field
Code: [Select]
last -20 -a
// w : shows who is currently logged in and where they are logged in from.
Code: [Select]
w
// netstat : shows all current network connections.
: shows all connections to the server, the source and destination ips and ports.
Code: [Select]
netstat -an: shows routing table for all ips bound to the server.
Code: [Select]
netstat -rn
 
// top : shows live system processes in a nice table, memory information, uptime and other useful info. This is excellent for managing your system processes, resources and ensure everything is working fine and your server isn\'t bogged down.
Code: [Select]
top -crun top then type Shift + M to sort by memory usage or Shift + P to sort by CPU usage. Type "q" to quit.
 
// ps: ps is short for process status, which is similar to the top command. It\'s used to show currently running processes and their PID.
A process ID is a unique number that identifies a process, with that you can kill or terminate a running program on your server (see kill command).
: shows processes for a certain user
Code: [Select]
ps U username: shows all system processes
Code: [Select]
ps aux: shows all system processes like the above but organizes in a hierarchy that\'s very useful!
Code: [Select]
ps aux --forest
// file : attempts to guess what type of file a file is by looking at it\'s content.
: prints out a list of all files/directories in a directory
Code: [Select]
file *
// du : shows disk usage.
: shows a summary, in human-readble form, of total disk space used in the current directory, including subdirectories.
Code: [Select]
du -sh: same thing, but for each file and directory. helpful when finding large files taking up space.
Code: [Select]
du -sh *
 
// wc : word count
: tells how many lines are in filename.txt
Code: [Select]
wc -l filename.txt
// cp : copy a file
: copies filename to filename.backup
Code: [Select]
cp filename filename.backup: copies all files, retaining permissions form one directory to another.
Code: [Select]
cp -a /home/burst/new_design/* /home/common/public_html/
 
// kill: terminate a system process
: kill -9 (forceful) PID (process) number 431
Code: [Select]
kill -9 431Use top or ps ux to get system PIDs
 
 

[/indent]Feel free to comment or post more frequestly used shell commands :)
« Last Edit: December 05, 2005, 04:32:38 AM by dynaweb »
Those who cannot learn from history are doomed to repeat it. -- Linux learns.

zelo

  • Super Moderator
  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 264
  • Karma: +10/-0
    • ICQ Messenger - 233717
    • MSN Messenger - webmaster@zelo.com
    • Yahoo Instant Messenger - zelo@yahoo.com
    • View Profile
    • http://www.zelo.com
    • Email
Commonly Used Shell Commands
« Reply #1 on: August 02, 2005, 05:20:57 PM »
SUPERB! This is a thread that can be used even for those who have been around the Linux arena for quite a while and those who have never written one command.

adb22791

  • Former Moderator
  • Full Member
  • ***
  • Posts: 149
  • Karma: +10/-0
    • ICQ Messenger - 226098809
    • View Profile
    • Email
Commonly Used Shell Commands
« Reply #2 on: October 15, 2005, 03:49:10 PM »
Another one that I find useful...

 
Code: [Select]
cat /etc/passwd/

Will show you all the users on your *nix box and their home directories.
-Alex

LinuxSon

  • Newbie
  • *
  • Posts: 4
  • Karma: +10/-0
    • ICQ Messenger - 219645035
    • MSN Messenger - asbaserujones@msn.com
    • View Profile
    • Email
Commonly Used Shell Commands
« Reply #3 on: September 25, 2006, 05:55:30 AM »
Thanx allot!!

I just finished registering to this forum, and I really look forward to getting involved!!
Thanx again for the command list
I am new to Linux, but I love it to death!!

AJ

zelo

  • Super Moderator
  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 264
  • Karma: +10/-0
    • ICQ Messenger - 233717
    • MSN Messenger - webmaster@zelo.com
    • Yahoo Instant Messenger - zelo@yahoo.com
    • View Profile
    • http://www.zelo.com
    • Email
Commonly Used Shell Commands
« Reply #4 on: September 25, 2006, 09:58:05 AM »
Is there a way to get all this in one message so that it can be printed out instead of a bunch of little messages I have to wade through. It would make life a lot easier for me.

nebula

  • Newbie
  • *
  • Posts: 27
  • Karma: +10/-0
    • View Profile
    • Email
Commonly Used Shell Commands
« Reply #5 on: June 22, 2008, 03:33:04 PM »
^^^ wot he said

yes thank you for this gonna have to copy out to Rombiy notes of similar

nebula

  • Newbie
  • *
  • Posts: 27
  • Karma: +10/-0
    • View Profile
    • Email
Commonly Used Shell Commands
« Reply #6 on: July 06, 2008, 11:37:34 AM »
THANK YOU
I just copied it all out to Tomboy notes for ease of access

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
174 Views
Last post December 16, 2005, 05:01:08 AM
by Linux News
2 Replies
1839 Views
Last post January 15, 2006, 12:36:50 AM
by dynaweb
0 Replies
180 Views
Last post December 18, 2005, 09:28:31 AM
by Linux News
4 Replies
1792 Views
Last post January 09, 2006, 09:48:08 PM
by dynaweb
0 Replies
1527 Views
Last post September 17, 2006, 11:20:00 AM
by dynaweb