Unix is a open source multi-tasking operating system which was developed in 1969 by a group of AT&T employees at Bell Labs. I am not going to discuss whole history of Unix here and make this post boring. I am very big fan of open source operating system Linux, which is evolved from Unix and its first kernel was developed by Linus Torvalds. Today Linux operating system are widely used in home desktop, laptops, web-hosting server’s and even in super computers.
Today latest mobile revolution operating system, Android also run on Linux kernel. Today, I am gonna discuss about some basic Linux command, which I use every day and are very helpful if you are Linux administrator.
Everyday Basic Linux Commands with Examples
1. uname: This command is very useful in verifying server name. When you type this command in your UNIX machine, it will print name, version and other details about the current machine and server.
$ uname -a : This command will print the server or machine name along with server version.
2. df : This is a system information command which is used to show disk usage. This command is always used when system administrator handle Filesystem issue in Linux or Sunos server’s or system’s.
$ df -h or df -k
Above command will show disk usage of all the mounted disk in human readable form like GB and MB. This command does not work on Solaris 8. For that you will have to use K instead of h like #df -k
$ df -h / : This Will show root disk usage.
$ df -h /opt : Will show /opt disk usage.
$ df -h /var : Will show /var disk usage.
3. date : This is very common UNIX command which is used to see date of the system. If you are working on different time zone, then this command is very helpful.
$ date : Will display the current date of the system.
4. uptime : This command is used to show current uptime of the machine. Suppose you have a server which is running from 120 days, and when you input this command, you will get output 120. This command can be used to know the last boot date of the system though there are other command for this.
$ uptime : This will show for how long system or server is up.
5. du : This command when entered will show directory space usage of that particular directory.
$ du -sh .: This will show your current directory usage in GB or MB.
$ du -sh * : This command will show all the current usage of the directory and files present in particular directory.
6. pwd : This command stands for Present Working Directory and show my present working directory in Linux and SUN operating system.
$ pwd : /home/tech2blog
7. ls : This command is useful when you need to see all the files in any directory or filesystem.
$ ls : This will list all the files under which this command is run.
$ ls -al : This will show all the files including hidden files in Linux system.
8. cd : This command stands for change directory and is used to go to particular directory. It is similar to windows command prompt command.
$ cd / : Will change your directory to root (/).
$ cd /var : Will make /var your present working directory.
9. cp : This command is used to copy files from one directory to another or within directory with different names. This Linux command is extensively used for taking backup of any file.
$ cp /etc/test1 /etc/test2 : This will copy test1 file in /etc with new name test2 in same directory etc. If you are currently in /etc only, then you can directly use file name.
$ cp -p /etc/passwd /etc/passwd.backup : Suppose you want to take backup of your /etc/passwd files, then you can use above command to take a backup of passwd file with all permission as original file.
10. mv: This is move command and is used to move the file from one location to other. Don’t confuse this with Copy command. This command can also be used to rename any file.
$ mv testfile.txt testfile2.txt: As shown above this command will rename file with name testfile.txt to testfile2.txt
$ mv testfile.txt /home/pawan: Now this command will move testfile.txt from its present location to /home/pawan. Here our present working location is /home/pawan/tech2blog
11. cat : This command is used to see content of any file. This command can also be used to copy text files, combine text files & create new text files.
$ cat /etc/group : This command will display all the content in group file in /etc.
These were some of the very basic Linux/Unix commands. Let us know how you like our post on basic Linux commands which we use frequently while working on Unix environment. You can also download your complete basic Linux/Unix command guide. If you like the post, please consider it sharing.