Shell Tips

From WikiDLXTV
Revision as of 05:19, 20 March 2010 by Asfaltboy (Talk | contribs)

Jump to: navigation, search

<<Page in construction>>

Common Shell Commands

I've put together some of the useful shell commands that are available under WDLXTV (using SSH or Telnet). They're organized alphabetically, so you can easily find a command, their description and how to use it. This guide will continue to be updated and if you would like to add to this guide, please edit after checking the command yourself.

  • ls : list files/directories in a directory, comparable to dir in windows/dos.
ls -al : shows all files (including ones that start with a period), directories, and details attributes for each file.
  • cd : change directory (ex: cd /usr/local/apache will go to /usr/local/apache/)
cd ~ : go to your home directory
cd - : go to the last directory you were in
cd .. : go up a directory
  • cat : print file contents to the screen (ex: cat filename.txt : cat the contents of filename.txt to your screen)
more : like cat, but opens the file one screen at a time rather than all at once (browse through the file, hit Space to go to the next page, q to quit)
tail : like cat, but only reads the end of the file. ex:
tail /var/log/messages : see the last 20 (by default) lines of /var/log/messages
tail -f /var/log/messages : watch the file continuously, while it's being updated
tail -200 /var/log/messages : print the last 200 lines of the file to the screen
  • chmod : changes file access permissions. (usage: chmod permissions filename)
Permission Table
# permission meaning
0 --- No permission
1 --X Execute only
2 -W- Write only
3 -WX Write and execute
4 R-- Read only
5 R-X Read and execute
6 RW- Read and write
7 RWX Read, write and execute
  • permission is a set of 3 numbers in this order from left to right: USER - GROUP - EVERONE. The three digits can be 0-7 as shown in the table on the right:
ex: chmod 000 file1 means No one can access file1, chmod 777 file2 means Anyone can access /write to/execute file2
  • chown : changes file ownership permissions. The permission set is of 2 parameters going from left to right: USER.GROUP (ex: chown root myfile.txt : Changes the owner of the file to root, chown root.root myfile.txt : Changes the owner and group of the file to root)
  • nano : friendly, easy to use file editor (ex: pico /conf/S00user-script : edit the custom options user file)
  • vi : another editor, tons of features, harder to use at first than nano, read more info here.
  • grep : looks for patterns in files, ex:
grep root /etc/passwd : shows all lines with the string root in file /etc/passwd
grep -v root /etc/passwd : shows all lines that do not match string root




  • ln : create's "links" between files and directories, ex: 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 original, however you can delete the link and it will not delete the original.
  • last : shows who logged in and when, ex:
last -20 : shows only the last 20 logins
last -20 -a : shows last 20 logins, with the hostname in the last field