Hello everyone 🙂 anukram here and today I came up with exciting things you all want to know: Linux commands. Today in this article we will discuss most Linux commands and their description example with their working and logic behind them.
Linux is first introduced in 1991, as in CLI (Command line interface). Which is designed for developers and programmers for making their work easy. But most people when they hear the word Linux think, ohh Linux CLI is very complicated and hard to use for regular people. Sometimes this thought is true because not everyone is able to use Linux. The person who wants to use Linux needs to practice and learn its commands for proper working.
So for beginners and even professionals if you missed any of the commands then this will help you with most of the Linux commands. After going through all the things written over here you’ll be able to know all the commands for basic starting in Linux OS.
Most probably Linux is used for many things server, deployment, security audits, security testing, maintaining services, etc. Linux is most popular is users who are involved in the security of any type like network security, computer security, mobile security, server security, etc.
Linux Commands you should know
So let’s start with having a look at all the commands over here
command | command full form | syntax | Function |
---|---|---|---|
cd | Change Directory | cd | It is used to bring you back to your home directory |
cd | change directory | cd ../ | it will bring you one directory back |
cd | Change directory | cd ../../ | brings you two directories back |
pwd | Present working directory | pwd | It is used to check which directory you’re working |
ls | list | ls | this cmd shows you the all items in your present directory |
ls -R | list items | ls -R | it will list all items in your directory with all items in sub-directories. |
clear | Clearing | clear | this is used to clear your terminal or screen. You can do it by using CTRL+L. |
mkdir <name for directory> | Make directory | mkdir test-directory | this command will create a directory with the name test-directory. Basically, it is used to create new directories. |
touch <file-name> | Touch | touch new-file.txt | so this creates a text file named new-file in your directory. basically, this command is used to create new files which could a text, bat, word, etc. |
rm <file-name> | Remove | rm new-file.txt | this will delete your file which is new-file.txt permanently. This command is used to delete files only. |
rmdir <directory-name> | Remove Directory | rmdir test-directory | this will delete the test-directory but only if the test-directory is empty or else it will give an error that the directory is not empty. So this command is used to delete empty directories. |
rm -r <directory-name> | Remove directory recursively | rm -r test-directory | This deletes your test-directory if it is containing anything in it then also it will remove it. So this command is used to delete any directory either if it contains any document. |
sudo | SuperUser Do | sudo <command you want to run> | sudo enables the admin or privileged user permission with any command. If you want to run any command as root then you need to use sudo before the command. |
sudo su | SuperUser Do Switch User | sudo su | it will switch you to root user privileges. Basically, sudo su is used for switching between the different users in the OS. |
apt-get update | Aptitude Get Update | sudo apt-get update, sudo apt update | this is used to resynchronize your packages by the help source.list file from your OS. In general terms, you can say that this is used to sync your application to the current day for getting updates. |
apt-get upgrade | Aptitude get upgrade | sudo apt-get upgrade, sudo apt upgrade | this will upgrade or update your application or package to its newest version. it will update your installed packages and application to their latest or newest version. |
apt-get full-upgrade | aptitude get fully upgrade | sudo apt full-upgrade | this command will fully upgrade all packages and applications, and it will delete the old version of it. With this command, we can save disk space while upgrading our packages and application. |
apt-get install | Aptitude get install package | sudo apt-get install <package-name> | this command will help you to install any package or application from the terminal. |
user add | Adding a new user | sudo useradd <user-name> | So basically this command is used to create a new user into the OS. |
man | manual | man <command-name> | this is used to get all the information of how this command is working in background. |
passwd | Password set | sudo passwd | this command is used to change root user login password |
passwd | Password set | sudo passwd <user-name> | again same command but this command is used to change the login password of a particular user |
whoami | Check user | whoami | this is used to check the current logged-in user’s name from terminal |
bash | Bash Shell | bash | this is used to enter in the bash shell mode |
chown | Change ownership | sudo chown <user-for-assinging:group-name> <file-name> | so this command is used to change the ownership of any file to any user and group. |
usermod | Moderating user | sudo usermod -a -G <group-name> <user-name> | this command is used to add any user to any group. here in the command -a=add, -G= group-name. |
userdel | Delete User | sudo userdel <user-name> | By this, you can delete any user |
cp | Copy | sudo cp <file-name/dir-name> <path> | this will help with copying anything from one place to another |
mv | Moving | sudo mv <file-name/dir-name> <path> | this is the same as copy command but here we are moving the thing which means it will get deleted from its last location |
Permission Management on Linux
Permission | Number |
---|---|
Read permission | 4 |
Write Permission | 2 |
Execute Permission | 1 |
No Permission | 0 |
To change the permission of any file
chmod <permission-number> <file-name\\directory-name>
imagine that we have a file test.txt and we want o give read,write,and execute permission to user and read and write permission to group and read permission for others then
chmod 764 test.txt
To give/remove execute permission for other user
chmod o+x <file-name>
for removing execute permission
chmod o-x <file-name>
command for checking the path of password and shadow file
path of password file is /etc/passwd
path of shadow file is /etc/shadow
Note:- password file is owned by the root. So by this, we can say that the user root has the read and write permission of the password file. Shadow has also the same permission as the password file with the root user.
Shadow file is a very confidential file for our system because it contains all password hashes in it.
If you have any queries regarding the above content, or you want to update anything in the content, then contact us with your queries. You can directly post your question in the group.
Connect with us on these platforms