Display the current directory path you are in.
pwd
Change directories
cd directory
cd path\to\directory
Create a new directory
mkdir directory_name
Delete an empty directory
rmdir directory_name
Delete a directory and all sub directories/files.
rm -rf directory_name
----------
Files :- ls, ls -l,ls -la, cp, mv, rm, rm -i
List files in a directory
ls
ls -l
ls -al
copy a file to another filename.
cp filename1 filename2
move or rename a file.
mv filename1 filename2
mv filename1 directory\filename2
Delete a file (with rm you will not usually get a prompt to confirm)
rm filename
rm -i filename
--------------
Shortcuts :- cd, alias
Go to a directory within your home directory.
cd ~/directory
Change to your home directory
cd (by itself)
Go back 1 directory in the tree
cd ..
Create your own shortcuts for a command
alias shortcut='full command'
See a list of shortcuts that you have already created.
alias (by itself)
----------------
Search :- find, grep
Locate a file on the shell (looking in all sub directories)
find . -name filename -print
look for a file that contains a specific word and/or phrase .
grep word file(s)
grep blowfish *
-------------------
Getting Help :- man, apropox
Look up in the manual for information on a command
man command
Getting help when you have an idea of what to do but do not know what the relavent command is.
apropos word
-----------------------
Extract archives :- tar, unzip, gunzip
decompress a .tar.gz file:
tar -zxvf filename
decompress a .tar file:
tar -xvf filename
decompress a .zip file:
unzip filename
decompress a .gz file:
gunzip filename
-----------------
System :- ps, kill, uptime
Display basic information about current running processes.
ps x
Display more detailed information about runnging processes including memory/process usage.
ps ux
Kill a process corresponding to a PID number.
kill -15 #PID (Only use kill -9 #pid if your bot does not respond to a kill -15 #pid signal)
kill -9 #PID
kill -9 11542
Kill / Terminate all running processes in your account.
kill -15 -1
kill -9 -1
The uptime shell command shows the time since the system was last booted, the number of active user processes and a final column showing something called load averages. The 3 Values for load averages are taken from the last 1, 5 and 15 minutes and represent CPU utilisation.Ideally a load average below 1 is ideal, when you start to commonly see averages above 2 you should consider investing in a new server or upgrades to current hardware. You will notice high load average by poor response times from the machine.
uptime
-----------------
Chmod :-
Chmod changes the access privaledges on a file making it readable, writable and/or executable. It defines which users may have access to a file and how much access they have.
This column shows what access a file already has and is split into 3 sections, which can be represented by letters.
User Group Others/Everyone
- rw- r-- r--
u The User who owns the file (this means “you.”)
g The Group the file belongs to.
o The Other users.
a All of the above (an abbreviation for ugo)
To change the access permissions of a file you use the command chmod as discussed a little later.
Letter Correspnding Number Definition
r 1 Permission to Read a file (list a directory).
w 2 Permission for Writing to and deleting files and/or directories.
x 4 Permission to eXecute (run) a file.
The octal (0-7) value is calculated by adding up the values for each digit
User (rwx) = 4+2+1 = 7
Group(rx) = 4+1 = 5
Others (rx) = 4+1 = 5
chmod mode = 755
change the permissions on a file.
chmod who=permission(s) filename
chmod numbers filename
We will show you some examples of both these mothods using this file:
permissions before Commands permissions after
-rwxr-xr-x chmod 700 file.conf -rwx------
-rwxr-xr-x chmod go= file.conf -rwx------
-rwxr-xr-x chmod u=rw file.conf -rw-r-xr-x
-rwxr-xr-x chmod 555 file.conf -r-xr-xr-x
Personally i prefer using the numbers as opposed to letters to represent permissions on a file.
---------------
About yourself :- whoami, passwd, quota, du, last
Display what username you are currently logged on under
whoami
Change your password
passwd
Display your current quota on the shell
quota -v
Display current disk usage of a filename and/or directory. Without an option it will use the current directory. du -s will only give a total.
du filename/directory
Shows a list of your last logins
last YourUsername
----------------
Accessing external sites :- ftp, wget, lynx, telnet
Accessing an ftp site from your shell
ftp hostname
ftp ftp.url.org
common commands to remeber using ftp are get, dir, cd. You can type help command at any time while using ftp on your shell.
Getting a file directly from an http or ftp site without logging in.
wget file
wget ftp://somewebsite.com/filename.zip
wget http://www.somwhere.org/download/file.tar.gz
Browse the web from an ordinary terminal, type H at any time to learn more about lynx
lynx
To connect to a remote host you can use telnet as follows:
telnet hostname
--------------------
Please report inaccuracies or errors that I have made to hemant@allaboutunix.com
No comments:
Post a Comment