Basic command in Linux Every User Should Know

2490
Basic command in Linux
Basic command in Linux

Basic command in Linux Every User Should Know

Now, let us look at the most important and basic command in Linux.  Linux commands are case sensitive hence you need to be careful about what you are keying in.

File Management becomes easy if you know the right commands.

Sometimes, commands are also referred to as “programs” since whenever you run a command, it’s the corresponding program code, written for the command, which is being executed.

Basic command in Linux

1. ls –

List directory contents. If you know windows you would know that the command dir is used to list the contents in a directory. In Linux, the ls command is used to list out files and directories. Some versions may support color-coding. The names in blue represent the names of directories.

ls -l | more – this helps to paginate the output so you can view page by page. Otherwise the listing scrolls down rapidly. You can always use ctrl c to go back to the command line.

$ ls
-l filename

There are variations you can use with the ls command:

  • ls -R will list all the files in the sub-directories as well
  • ls -a will show the hidden files
  • ls -al will list the files and directories with detailed information like the permissions, size, owner, etc.

2. cd /var/log –

Change the current directory. The forward slash is to be used in Linux. The example is a Linux directory that comes with all versions of Linux.

When you use ls –I you will be able to see more details of the contents in the directory

It will list down the

  • Permissions associated with the file
  • The owner of the file
  • The group associated with the file
  • The size of the file
  • The timestamp
  • The name of the file

There are some shortcuts to help you navigate quickly:

  • cd .. (with two dots) to move one directory up
  • cd to go straight to the home folder
  • cd- (with a hyphen) to move to your previous directory

3. pwd – Print Working Directory

One way to identify the directory you are working in is the pwd command

It displays the current working directory path and is useful when directory changes are often

An example of an absolute path is /home/username.

4. su / sudo command –

There are some commands that need elevated rights to run on a Linux system. So you run them as a System Administrator which normal users cannot do.

Short for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions. However, it is not advisable to use this command for daily use because it might be easy for an error to occur if you did something wrong.

Example – shutdown command the shutdown command safely turns off the computer system.

  • sudo shutdown 2 – shutdown and turns of the computer after 2 minutes
  • sudo shutdown –r 2 – shuts down and reboots in 2 minutes
  • Using ctrl C or shutdown –c helps in stopping the shutdown process.
$ sudo shutdown 2
$ sudo shutdown –r 2

5 mkdir – to make a directory.

mkdir

 if you would like to create a directory in the name ‘myproject’ type

mkdir
myproject

There are extra mkdir commands as well:

  • To generate a new directory inside another directory, use this Linux basic command mkdir Music/Newfile
  • use the (parents) option to create a directory in between two existing directories. For example, mkdir -p Music/2020/Newfile will create the new “2020” file.
$ mkdir myproject

6. cat –

The cat command (short for “concatenate “) is one of the most frequently used commands in Linux. cat command allows you to create single or multiple files, view contents of file, concatenate files and redirect output in terminal or files.

Here are other ways to use the cat command:

  • cat > filename creates a new file
  • cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them in a new file (3)
  • to convert a file to upper or lower case use, cat filename | tr a-z A-Z >output.txt
$ cat file.txt
$ cat file1.txt file2.txt

7. mv – Move a file

The primary use of the mv command is to move files, although it can also be used to rename files.

Here the file name gets changed from first.txt to second.txt.

$ mv first.txt second.txt

8. cp – Copy a file

cp source file destination file. In case you need a copy of the file second.txt in the same directory you have to use the cp command

$ cp second.txt third.txt

You can use ls – l to see the new file created. The two files will be exactly of the same size.

To Sum Up- Basic command in Linux

Basic Linux commands help users execute tasks easily and effectively. It might take a while to remember some of the basic commands, but nothing is impossible with lots of practice.

Join Telegram Group of Daily Jobs Updates for 2010-2023 Batch: Click Here

If You Want To Get More Daily Such Tech Updates, Career Advice Then Join the Telegram Group From Above Link And Never Miss Update.

Accenture Hiring Freshers of Package 4.5 LPA Across India: Click here

Why You’re Not Getting Response From Recruiter?: Click here

Top 5 High Salary Jobs in India IT Sector 2020: Click here

How To Get a Job Easily: Professional Advice For Job Seekers: Click here

A Leadership Guide For How To Win Hearts and Minds: Click here

COVID-19 Live Tracker India & Coronavirus Live Update: Click here

Career Tips for Freshers: Top 7 Hacks To Land Your Target JobClick here

Top 5 Best Indian Car Launches In December ahead: Click here

Feel Like Demotivated? Check Out our Motivation For You: Click here

Top 5 Best Mobile Tracking App in 2021 For Mobile & PC: Click here

5 Proven Tips For How To Look Beautiful and Attractive: Click here

Home Workouts During The Lockdown For Fitness Freaks: Click here