Basic cmd you must know
- pwd - Prints out on the screen the working directory (eg /etc/ssh)
- cd - changes directory (eg cd .. - goes up one dir; cd etc - enters /etc dir)
- ls - lists the content of the directory
- mkdir - creates a new directory (mkdir dir_name)
- touch - creates a new file (touch file_name)
- rmdir - removes a directory (rmdir dir_name)
- cp - copies a file/directory (cp source_file destination_file)
- mv - moves a file/directory - also used for renaming a file or directory
(mv old_location new_location or mv old_name new_name)
- rm - removes files (rm file_name)
To search a file, you can use
- find
- grep
To view a file, you can use
- more
- cat
- head
- tail
To edit a file you must use a built-in editor from the command-line. Generally, this is vi and it's used with the syntax vi
To uncompress an archive (usually tar.gz) you must use the tar command with the syntax tar -xvzf
To print a file, use lpr
To remove a file from printer queue (you can list the queue with lpq command) you can use lprm
To mount/unmount (add in your file system as accessible media) use:
- mount /mnt/floppy - to mount floppies
- umount /mnt/floppy - to unmount floppie
- mount /mnt/cdrom - to mount CD-ROMs
- mount /mnt/cdrom - to unmount CD-ROMs
They usually mount automatically, but you could end-up in the situation where you must do it manually.
To mount a partition:
First create a directory in /mnt (mkdir /mnt/my_new_drive) then use the mount command (mount /dev/source /mnt/my_new_drive) where /dev/source is the device (partition) you want to mount in your file system.
If you want to connect to a remote host, use the ssh command. The syntax is ssh
System management:
- ps - shows the current processes running (useful: ps -A shows up all processes)
In the list obtained by using ps command you will see a PID number (Process identification).
This number is required to stop a service or application. Use kill
- top - works somehow like the Task manager in Windows. It shows up the system resources, the processes running, average load, etc. Useful is top
-d
- uptime will display the system's uptime and the load average for that moment, 5 minutes and 15 minutes in the past.
Usually, the load average is calculated as the percent of system resources (processor, RAM, harddisk I/O, network load) used at that moment. 0.37 means that 37% was used. A greater value like 2.35 means that the system had to que some data because it should be 235% faster to compute all without problems. Anyhow, this can be different from distribution to distribution.
- free - will display information on system's memory
- ifconfig
- passwd - enables you to change your password (passwd own_user or others if you are logged in as root)
- useradd - enables to add a new user (see man useradd)
Anywhere you are, you cand use the TAB key to autocomplete a filename or command. This will be usefull when getting used to the commands available. You can also hit up arrow and down arrow to scroll through the history of the commands you entered.
You can also use multiple command on one line. Let's say you want to create 3 directories at once. The syntax is mkdir dir1 ; mkdir dir2 ; mkdir dir3.
Another useful thing is the pipe command. You can get a command output through another. Eg: man mkdir | tail will display the last lines in the manual pages of the mkdir command.
If at anytime you are asked for the root account (the super-administrator of the system) you can login in temporary with it by using the su command. You should also include -l (su -l) parameter to switch the home folder and available commands too. Note that you will be prompted for a password too.
To exit the shell type exit or logout.
thanz n credit to cyber terrorist
No comments:
Post a Comment