Basic Linux Commands - 2

 Linux Basic Commands - 2

Basic Linux Commands - 2

Hey guys today we are going to take a look at some more Linux commands that you would need in your journey 

List of Contents:- 

  • sudo command
  • pwd command
  • cp command
  • mv command
  • history command 

Commands and their use cases

If you have a windows machine you can make a Linux docker container in your system, I have made the Docker tutorial

1) sudo:- 

sudo stands for superuser do  

sudo command is used when you want to do something that needs more privilege to do that stuff, it is also called root privilege( Note you only need the root privilege to do certain things if it's needed or you are logged in as another user ---- means if you are logged in as a root user you don't need the root privileges or sudo permissions to do stuff. ) 

 Like if you want to update or upgrade your system or you want to do something in the / directory (We will see Linux system directories in the future blogs) there are so many use cases when you need root permission which you will find when you start getting your hands on Linux.


Basic Linux Commands - 2

 As you can see in the above example we have tried to update the system without using the sudo command and it gives us some errors and warnings, the thing that the terminal wanted to say here is that ( man you don't have enough permissions so we can't help you here... Then we used the prefix sudo which means ( I am the boss and I am giving you order to update the system ) You are going to need to use the sudo command many times in your Linux journey  


2) pwd:- 

As the command means print working directory as the name itself suggests that it is going to print the name of the directory you are currently working in.


Basic Linux Commands -2

As you can see in the above example on entering the command pwd it prints the working directory from the absolute ( / directory ) 

 3) cp:- 

The cp command is used to copy something...

The syntax for the cp command is like cp path-of- file/directory  path-to-store  

As we can see in the above example first we have created a directory named testing then we used the cp command to copy the user.txt file to the folder... 

You can also move the entire files to the directory you just have to use the * ( this reference to everything in the directory ) so the example command would be cp * testing/ 

3) mv:-  

mv command is the same as cp command where the cp command stands for copy the mv command stands for a move ( or if you are familiar with windows you can say it as a cut option )

As in the cp command, the file or directory gets a copy whereas in the mv command they get moved from one space to another 

The mv command is also used to rename the file in Linux 

Basic Linux Commands -2

As you can see above we have used the mv command as a mover but we can also use the mv command as a renamer 

Basic Linux Commands -2

3) history:- 

As the name states the history command use used to print the terminal history. 

Basic Linux Commands -2

Basic Linux Commands -2


As you can see above the history command just simply gives the terminal history. 

It's a file that is stored in the user directory as I am using the zsh shell the file is stored with the name of .zsh_history ( you can also notice that it's a hidden file )  

Bonus tip:- 

If you don't want your history to be logged just give leave a space before typing the command ( Note:- this behavior is stored in the configuration file and can be changed  ).


Conclusion:- 

From this article, we have studied the 5 more basic commands of Linux that you will need in your Linux journey 


Stay tuned ✌✌

 

Next Post Previous Post
No Comment
Add Comment
comment url