Skip to main content

Command Palette

Search for a command to run...

Unlock Linux Potential: Sudo and Advanced Command Tips

Published
4 min read
Unlock Linux Potential: Sudo and Advanced Command Tips
M

Hi, How are you !! Hope you doing good....

I got introduced to Cloud initially. As I went ahead learning what is cloud and how it works, then got to know a field which is DevOps that makes Cloud model more effective.

So, as I started working & got good experience on AWS. I have been learning the DevOps tool and technologies on how to use it with the Cloud, which will give me good understanding on how Cloud and DevOps go hand in hand to deploy my applications.

  1. What is Sudo →

    sudo is superuserdo, which is a group that has all the permission similar to the root user, that's why whenever we want to do task which can be done by only root user we write sudo command.

    We can see the permission of root user and sudo group in directory - "/etc/sudoers" & command for that is - "sudo cat /etc/sudoers" to make it look more properly write command - "sudo vim /etc/sudoers" (vim is the editor). Sudo is a special privilege when ever we use it before a command then Linux thinks that root user wants to execute that command. So, if we create a user and add the user in the sudo group then that user has all the permission to perform anything and doesn't require to use "sudo" command to perform root user actions.

  2. What is sudoer's file →

    It is a file which is used by the administrators to allocate the system rights to the system users, which allows the administrators to control who does what. So, all the permission's given to a user or user-group is specified in the sudoer's file.

  3. Advanced Linux Commands

  • Which command is used to find current user → whoami

    ubuntu@ip------:~$ whoami

    ubuntu

  • Which command is used to print details of the current user → who -H

    ubuntu@ip--------:~/scripts$ who -H

    NAME LINE TIME COMMENT

    ubuntu pts/0 2023-09-19 10:05 (18.206.107.29)

  • Which command is used to determine system uptime i.e. it provides additional information like current time, number of active users, load averages → uptime

    ubuntu@ip--------:~/scripts$ uptime

    12:23:57 up 2:18, 1 user, load average: 0.00, 0.00, 0.00

    So, it shows time of the machine, machine is running so "up", "2:18" machine started 2 hours 18 minutes ago, as we have logged in the machine only once so it shows 1 user. If I ssh the EC2 machine from my local machine then it will show the no. of user's as 2 why because the EC2 machine is logged in from EC2 connect and from my local machine as well. If i disconnect/log-out/exit the ssh connection to EC2 machine from my local machine then the user's will be 1 user and not 2 user why because we have logged out to the EC2 machine from ssh. So, currently there is only one user who is logged in to the EC2 machine.

  • Which command is used to locate the paths of executable files → which

    ubuntu@ip-------:~$ which mkdir

    /usr/bin/mkdir

  • What is the command to see the memory usage → free

  • Which command to list the CPU's on the machine → nproc

  • What is the command to see the disk usage (disk file) → df -dh / df -h

    -h means its human readable

  • What is the command to look into the CPU, memory(RAM), processes of the machine at once in Linux → top

  • What is the difference between curl and wget

    curl \= It will just retrieve the data from internet and display in the o/p. But it will not save the data in the machine

    wget \= It retrieves the data from internet by downloading the data and creates a file for it and saves the downloaded data into the file in the Linux machine

  • Which command is used to display memory usage data in gigabytes → free -g

    -g represents gigabytes. So, if use "free" then the data will be showed in kilobytes, but if we have a system where the data is huge then always better to use "free -g" as "free" will show the data in kb which is not readable.

  • Which command is used to list all the file with all the information, date and time of creation. The oldest one created will be shown at the top. → ls -altr

“““ Hope you had a great time going through the above sudo and advanced linux commands, which will help you to get the additional details work done in Linux OS. Please like, share and comment if you liked it and connect with me for more information…..”””

More from this blog

Mihir's Tech blog

69 posts