Basic Unix and Linux Commands With Examples

  • Updated
  • Posted in Programming
  • 3 mins read


Learning unix working system could be very straightforward. It is simply that you should perceive the unix server ideas and aware of the unix instructions. Here I’m offering some necessary unix instructions which will probably be utilized in day by day work.

Unix Commands With Examples:

1. Listing information

The very first thing after logging into the unix system, everybody does is itemizing the information in a listing. The ls command is used to listing the information in a listing.

>ls

add.sh
logfile.txt
prime.pl

If you merely execute ls on the command immediate, then it should show the information and directories within the present listing.

>ls /usr/native/bin

You can cross a listing as an argument to ls command. In this case, the ls command prints all of the information and directories within the particular listing you will have handed.

2. Displaying the contents of a file.

The subsequent factor is to show the contents of a file. The cat command is used to show the contents in a file.

>cat file.txt
This is a pattern unix file
Learning about unix server is superior

3. Displaying first few strains from a file.

The head command can be utilized to print the required variety of strains from the beginning of a file. The beneath head command shows the primary 5 strains of file.

>head -5 logfile.dat

4. Displaying previous few strains from a file.

The tail command can be utilized to print the required variety of strains from the ending of a file. The beneath tail command shows the final three strains of file.

>tail -3 logfile.dat

5. Changing the directories

The cd command can be utilized to alter from one listing to a different listing. You must specify the goal listing the place you need to go.

>cd /var/tmp

After typing this cd command you’ll be in /var/tmp listing.

6. Creating a file.

The contact command merely creates an empty file. The beneath contact command creates a brand new file within the present listing.

contact new_file.txt

7. copying the contents of 1 file into one other.

The cp command is used to repeat the content material of supply file into the goal file. If the goal file have already got knowledge, then it is going to be overwritten.

>cp source_file target_file

8. Creating a listing.

Directories are a means of organizing your information. The mkdir command is used to create the required listing.

>mkdir backup

This will create the backup listing within the present listing.

9. Renaming and transferring the information.

The mv command is used to rename the information and it additionally used for transferring the information from one listing into one other listing.

Renaming the file.

>mv file.txt new_file.txt

Moving the file to a different listing.

>mv new_file.txt tmp/

10. Finding the variety of strains in a file

The wc command can be utilized to search out the variety of line, phrases and characters in a file.

>wc logfile.txt
21 26 198 logfile.txt

To know in regards to the unix command, it’s at all times good to see the person pages. To see the person pages merely cross the command as an argument to the person.

man ls

Leave a Reply