- man - show manual and uses of command, uses man [command] hit q to exit the man page. example:- man useradd
- pwd - to show present working directory.
- useradd - to add a user, uses useradd [option] [uesrname] to assign different home directory other then /home use -d option, to add the user to a group use -g option, use -s to assign shell. example:-useradd -d /opt/tset(home dir location) -g game(group name) -s /bin/bash(shell name) test(username)
- passwd - to set or change password of user, uses passwd [username]. example passwd test to set password for test user.
- mkdir - to create directory, uses mkdir [directory name]. example mkdir test to create the test directory, mkdir /opt/james/old/test to create the test directory inside /opt/james/old.
- cd - change directory, uses cd [location to change]. example:- cd /temp
- ls - listing directory, uses ls [option] [location] . example:- ls /etc, use ls -l
/etc
to see more detail, ls -a /etc to see hidden file. - cp - copy a file or directory, uses cp [source] [dest]. example:- cp /opt/a.txt /etc/ to copy a.txt file for /opt to /etc, if you want to copy a directory use the -R option for recursive: cp -R /opt/Test /etc/os/ copy the Test folder from /opt to /etc.
- mv - move or rename a file or directory, uses mv [source] [dest]. example mv /usr/local/a.sh /etc/ to move the file a.sh from /usr/local to /etc, mv test.txt a.txt to rename test.txt file to a.txt.
- rm - remove a file or directory, uses rm [file or directory name]. example: rm a.txt to remove a.txt file to remove a directory you may need the -R option, you can also use the -f (forcefully) option which don't ask conformation for each file:- rm -Rf /dir but don't use -f option every time.
- cat - to read the content inside a file, uses cat [file name or location]. example cat a.txt to read the a.txt file content, cat /opt/test/test.txt to read test.txt from /opt/test location.
- tar - tape archiver, tar takes a bunch of files, and munges them into one .tar file, uses tar [option] file.tar [location of file or folder]. example:- tar test.tar /opt/test to tar the test folder for untar use untar file.tar
- find - lists files and directories recursively with matching string, uses find [location] -name [string]. example find /opt/ -name test to list all file and directory matching string test inside /opt
- tail - prints the last few lines of a file, this is handy for checking log files, uses tail [option] [file name or location]. example tail -5 ab.txt to print last five line of ab.txt file, tail -f /var/log/mail to see last 10 line of mail log file.
- vi - text editor, there are several text editors such as emacs, and nano, but vi is usually installed on any server so its a good one to learn. To edit a file type vi file to edit a line press Esc i then to save changes and exit use Esc wq, or to quit without saving use Esc q!. There are a million other commands, but that will enable you to edit files at a basic level.
Wednesday, February 10, 2010
The 15 Most Basic UNIX commands
Subscribe to:
Post Comments (Atom)
2 comments:
Great Tutorial...subscribed =)
good though i understood nothing _Babloo
Post a Comment