Difference between revisions of "Shell Tips"

From WikiDLXTV
Jump to: navigation, search
(Added)
 
(Added Shell Tips)
Line 1: Line 1:
= Page in construction =
+
= <<Page in construction>> =
  
 
= Common Shell Commands =
 
= Common Shell Commands =
Line 5: Line 5:
  
 
* '''ls''' : list files/directories in a directory, comparable to dir in windows/dos.
 
* '''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.  
+
: '''''ls -al''' : shows all files (including ones that start with a period), directories, and details attributes for each file.''
 
* '''cd''' : change directory  (ex: <code>cd /usr/local/apache</code> will go to '''/usr/local/apache/''')
 
* '''cd''' : change directory  (ex: <code>cd /usr/local/apache</code> 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:
 +
:: <code>'''tail /var/log/messages'''</code> : see the last 20 (by default) lines of /var/log/messages
 +
:: <code>'''tail -f /var/log/messages'''</code> : watch the file continuously, while it's being updated
 +
:: <code>'''tail -200 /var/log/messages'''</code> : print the last 200 lines of the file to the screen
 +
* '''chmod''' : changes file access permissions. (usage: <code>chmod permissions filename</code>)
 +
{| border="1" cellpadding="3" cellspacing="0" style="float:right; margin:.46em 0 0 .2em;"
 +
|+ '''Permission Table'''
 +
|-
 +
|<nowiki>#</nowiki> ||permission ||meaning
 +
|-
 +
|0 || align="center" |<nowiki>---</nowiki> ||No permission
 +
|-
 +
|1 || align="center" | --X ||Execute only
 +
|-
 +
|2 || align="center" | -W- ||Write only
 +
|-
 +
|3 || align="center" | -WX ||Write and execute
 +
|-
 +
|4 || align="center" | R-- ||Read only
 +
|-
 +
|5 || align="center" | R-X ||Read and execute
 +
|-
 +
|6 || align="center" | RW- ||Read and write
 +
|-
 +
|7 || align="center" | RWX ||Read, write and execute
 +
|}
 +
:* The 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: <code>chmod 000 file1</code> means '''No one''' can access file1, <code>chmod 777 file2</code> 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: <code>chown root myfile.txt</code> : Changes the owner of the file to root, <code>chown root.root myfile.txt</code> : Changes the owner and group of the file to root)''

Revision as of 04:58, 20 March 2010

<<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
  • The 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)