mikeyp
04-02-2006, 06:44 AM
(posted by mikeyp)
I got really bored and decided to write a small "help file" on some useful unix commands. The intended audience is those who are new to linux/unix and have no idea what to do in a shell. This is by no means a full list of every command you would need, but just a small drop in the pond. Feel free to add some if you'd like. If this is useful to others I will add some more later.
Notes:
file- some file that you wish to run a command on.
x- an integer.
command- some unix command.
path- a path to a file or directory, ex: /home/user123/ or /var/logs/log123.log
Most if not all options can be used together.
head <file>:
head prints the first few lines (10 by default) of a file. Very useful if you want to look at a few lines of a file without going into an editor. To print more/less lines use the -n option. The command would then be "head -n x file".
tail <file>:
tail prints the last few lines (10 by default) of a file. Very useful if you want to look at a few lines of a file without going into an editor. To print more/less lines use
the -n option. The command would then be "tail -n x file". tail also has a very useful option called "follow". If the file is edited it will print out the lines again. This is handy if you are looking at log files. The command would be "tail -f file". To use both the -n and -f options the command would be "tail -fn x file".
man <command>:
man is the unix manual command. If there is a manual entry for the command entered it will display all the options available and what they do. Extremely useful.
ls <path>:
ls shows the contents of the specified directory. If you just use "ls" it will display the contents of the current directory. The -a option shows all files, even hidden ones (hidden files have a '.' prefix in linuz/unix). The command would then be "ls -a". The -l option shows a long listing of each file in the directory (current or otherwise). It will show the files permissions, timestamp, owner, group and size among other things.
cd <path>:
cd is the change directory command. The path must be to a directory, not a file. If just "cd" is used it will take you to your home directory. To go one directory down use "cd ..".
mv <file> <path>:
mv is the move command. It will move the file/folder to the specified path.
cp <file> <path>:
cp is the copy command. It will copy the file/folder to the specified path. The original still exists.
(posted by Vege)
df -h //shows disk usage in human readable format
updatedb // followed by
locate X // find X string from your computer
(posted by nox-hand)
Chmod:
chmod <number code> <file name>
This command will change the permissions of the designated file. If you, for example, wanted to let EVERYBODY (I mean anyone here, not just your family or friends, but even someone else, like me !!), you'd use:
chmod 777 file.name
There are different number codes for what you need to do. I suggest you typing the following command to learn more about chmod:
Code:
man chmod
(posted by jatos)
ps -A
list all active processes
kill
kills a process with a given PID
init 123456
Change computers init level
shutdown
self explanatory really
chown
Change file ownership
(posted by Crouse)
Over 500 Linux commands:
http://www.linuxdevcenter.com/linux/cmd/
Tons of info on bash scripting : http://bashscripts.org
I got really bored and decided to write a small "help file" on some useful unix commands. The intended audience is those who are new to linux/unix and have no idea what to do in a shell. This is by no means a full list of every command you would need, but just a small drop in the pond. Feel free to add some if you'd like. If this is useful to others I will add some more later.
Notes:
file- some file that you wish to run a command on.
x- an integer.
command- some unix command.
path- a path to a file or directory, ex: /home/user123/ or /var/logs/log123.log
Most if not all options can be used together.
head <file>:
head prints the first few lines (10 by default) of a file. Very useful if you want to look at a few lines of a file without going into an editor. To print more/less lines use the -n option. The command would then be "head -n x file".
tail <file>:
tail prints the last few lines (10 by default) of a file. Very useful if you want to look at a few lines of a file without going into an editor. To print more/less lines use
the -n option. The command would then be "tail -n x file". tail also has a very useful option called "follow". If the file is edited it will print out the lines again. This is handy if you are looking at log files. The command would be "tail -f file". To use both the -n and -f options the command would be "tail -fn x file".
man <command>:
man is the unix manual command. If there is a manual entry for the command entered it will display all the options available and what they do. Extremely useful.
ls <path>:
ls shows the contents of the specified directory. If you just use "ls" it will display the contents of the current directory. The -a option shows all files, even hidden ones (hidden files have a '.' prefix in linuz/unix). The command would then be "ls -a". The -l option shows a long listing of each file in the directory (current or otherwise). It will show the files permissions, timestamp, owner, group and size among other things.
cd <path>:
cd is the change directory command. The path must be to a directory, not a file. If just "cd" is used it will take you to your home directory. To go one directory down use "cd ..".
mv <file> <path>:
mv is the move command. It will move the file/folder to the specified path.
cp <file> <path>:
cp is the copy command. It will copy the file/folder to the specified path. The original still exists.
(posted by Vege)
df -h //shows disk usage in human readable format
updatedb // followed by
locate X // find X string from your computer
(posted by nox-hand)
Chmod:
chmod <number code> <file name>
This command will change the permissions of the designated file. If you, for example, wanted to let EVERYBODY (I mean anyone here, not just your family or friends, but even someone else, like me !!), you'd use:
chmod 777 file.name
There are different number codes for what you need to do. I suggest you typing the following command to learn more about chmod:
Code:
man chmod
(posted by jatos)
ps -A
list all active processes
kill
kills a process with a given PID
init 123456
Change computers init level
shutdown
self explanatory really
chown
Change file ownership
(posted by Crouse)
Over 500 Linux commands:
http://www.linuxdevcenter.com/linux/cmd/
Tons of info on bash scripting : http://bashscripts.org