Basic Operational Commands In Linux For New Users [Ubuntu / Debian]

 
basic operation commands in Ubuntu Debian Linux


If you are new to Ubuntu/Debian then this post may be helpful to learn and operate your newly installed Debian/Ubuntu Linux. In this post we will see some basic operational commands which you should know if you are new to Ubuntu/Debian system.This commands only for those who are just trying out Ubuntu/Debian based Linux system.However many commands are commons with other distros.

a) how to add a regular user in sudoers file?

$ su - root  #switch to root

# echo "username  ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/username

where username = user account name
 
how to add user in sudoers file

b) how to add a new user ?

 $ sudo adduser 'username'
 
where username = user account name
 
how to add a new user in ubuntu

c) how to remove a user ?

$ sudo deluser 'username'
 
where username = user account name
 
how to delete a user account in Ubuntu

d) how to change the hostname ?


$ usermod -l 'new_username' -d /home/production -m 'old_username'

change or modify username of an account in Ubuntu


e) how to exit from current login session & get back to login screen in  Ubuntu?


$ loginctl terminate-session session_id  #gracefully

$ loginctl kill-session session_id #forcefully
 
Note : you can find the session id either by pressing tab key for current login user or use below command to get the session id for another user 
 

basic linux operational commands


f) how to get the session id for particular login user ?


$ loginctl list-sessions 

 
linux operational commands for new users newbees
 

g) how to terminate / exit from any login user account?


$ loginctl terminate-user 'username' #gracefully

$ loginctl kill-user 'username' #forcefully

Note: difference between session and user is that , a single user login into Linux machine with multiple sessions but if you specify the username it will close all the session login by that specific user.

Linux basic operational commands for new users newbees

g) check the username of currently login user account name


$whoami

h) how to shutdown system from terminal in Ubuntu?


$ sudo systemctl poweroff #if there is no another user login

$ sudo systemctl poweroff -i #forcely shutdown by ignoring another

login user

$ sudo systemctl restart #in order to restart system
 

h) how to create and extract the tar file from terminal in Ubuntu?


$ tar -cvf filename.tar /path #create tar file 
 
where path is the directory or file path which you want to tar

$ tar -xcvf filename.tar /path/ #extract tar
 
where path is the directory path where you want to extract tar file

g) how to check the ip configuration from terminal in Ubuntu?


There are many ways you can check the IP configuration in Ubuntu system. by default option is below.

$ ip -4 address #show basic ip v4 configuration
 
use -d option for detail configuration

$ hostname -i # show ip address v4/v6 of system

$ domainname -i # show ip address of system domain name  

$ networkctl status enp0s3 # show ip configuration for given link


h) how to install a package from terminal in Ubuntu ?


$sudo apt-get install 'package_name'
 

i) how to remove a package from terminal in Ubuntu?


$ sudo apt-get remove 'package_name' #only remove the binaries

$ sudo apt-get purge 'package_name' #remove package with all configurations

$ sudo apt-get autoremove # remove orphan packages

j) how to give read,write,execution permissions to a file in Ubuntu?


$chmod 755 'file_name'
 
where read = 4 , write = 2, execution = 1 and first digit for user, second for group, third for other => 755, So in this case , user has full permission ( 4+2+1) , group has read & execution permission (4+1) , other also has same as group.

Note: 000 will remove all permissions from all users and groups.


Linux ubuntu basic operational command for new users newbee


k) how to trace an website or an IP address from terminal in Ubuntu ?


$ apt-get install traceroute  #installing the traceroute package

$ traceroute ip_address  #tracing the IP/Web address

Linux basic operational commands for new users newbee
 

l) how to check machine-serial-number in Ubuntu system?


$demidcode -s baseboard-serial-number
 
basic Linux commands for newbee new users
 

m) how to change the current login user password from terminal in Ubuntu? 


$ passwd   # hit enter after typing passwd

$ ******  #type new password and hit enter

changing password for a user from root account 

# passwd 'username'  #where username is user account name

# *******

n) how to resolve domain name in Ubuntu?


DNS name can be resolved by nslookup utility which is not pre installed in Ubuntu/Debian base  desktop system . If nslookup utility not found in your system then you have to install the package bindutils

$ sudo apt-get install bindutils  #install the bindutils package

$ nslookup google.com  # resolving the google domain address
 
basic operational Linux commands for ubuntu new users
 

m) how to install firewall in Ubuntu Linux from terminal?


$ sudo apt-get install firewalld  

$ firewall-cmd --state     #check the current state of firewall services

n) manage firewall services in Ubuntu



o) creating a new file & renaming , deleting the file.


touch 'file_name'  #create a new blank file

mv 'old_name' 'new_name' #renaming file name

rm 'file_name'  #deleting a file

p) how to check the status of rules in iptables in Ubuntu?


$ su - root

#iptables -L -n #list all rules applied to system by iptables firewall
 
Note: please switch to root before executing this command
 
basic Ubuntu Linux operational commands
 

q) how to check the disk usage used by system mounted partitions in Ubuntu 


$ df -h
 

r) list the  System V init script services status.


service --status-all
 
 

s) how to check the hardware information in Ubuntu system.


lspci   #List all PCI devices.

lshw    #List hardware devices , install lshw package first

lscpu   #List cpu details

lsmem   #List memory details
 
lsblk   #List mounted block devices
 
lsusb    #List attached usb devices
 
lslogins #List all login devices, users, application daemons,services
 
Ubuntu Linux basic operational commands for new users newbee

 
Any improvement or recommendation will be appreciable.
 
Share post with your friends 😀
 
basic linux ubuntu commands

Post a Comment

0 Comments