Basic Linux Commands Description
pwd “Print Working Directory”. Shows the current location in the directory tree.
cd “Change Directory”. When typed all by itself, it returns you to your home directory.
Example: cd /home/
cd ~ “~” is an alias for your home directory. It can be used as a shortcut to your “home”, or other directories relative to your home.
cd .. Move up one directory. For example, if you are in /home/vic and you type “cd ..”, you will end up in /home.
Example: If you are in /etc/init.d/, after giving the following command "cd .." you will be in "/etc"
cd - Return to previous directory. An easy way to get back to your previous location!
ls List all files in the current directory, in column format.
ls -l List files in “long” format, one file per line. This also shows you additional info about the file, such as ownership, permissions, date, and size.
ls -a List all files, including “hidden” files. Hidden files are those files that begin with a “.”, e.g. The .bash_history file in your home directory. You can use more options like ls -lah, ls -ld for different types of output.
cat Display the contents of a text file on the screen. For example: cat <file-name> would display the file we created in the previous section.
head Display the first few lines of a text file. Example: head /etc/services
tail Display the last few lines of a text file. Example: tail /etc/services
tail -f Display the last few lines of a text file, and then output appended data as the file grows (very useful for following log files!). Example: tail -f /var/log/messages
cp Copies a file from one location to another. Example: cp <file-name> /tmp (copies the file-name file to the /tmp directory)
mv Moves a file to a new location, or renames it. For example: mv <file-name> /tmp (copy the file to /tmp, and delete it from the original
location)
touch Used to create empty files in Linux. Example: touch file1 file2 It will create two empty files named file1 & file2.
rm Delete a file. Example: rm /tmp/<file-name>
mkdir Make Directory. Example: mkdir /tmp/myfiles/
rmdir Remove Directory. Example: rmdir /tmp/myfiles/
To be continue.....
No comments:
Post a Comment