Linux – Root Commands (Faq)

1. su Change the effective user id and group id to that of USER

[sdbt ~]# su # default root(adminstrative)

[sdbt ~]# su sdbt # other su username
Password:

[sdbt ~]# su – sdbt # (-) will execute the bash profile of that user.
Password:

2. useradd create a new user or update default new user information

[sdbt ~]# useradd sdbt

[sdbt ~]# useradd sdbt5

3. passwd update user’s password

[sdbt ~]# passwd sdbt5

Changing password for user sdbt5.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.

5. usermod modify a user account

[sdbt ~]# usermod -c “welcome to SDBT” sdbt5

[sdbt ~]# usermod sdbt -p sdbt

[sdbt ~]# usermod -g oinstall sdbt5

[sdbt ~]# id sdbt5
uid=54348(sdbt5) gid=54321(oinstall) groups=54321(oinstall)

6. userde delete a user account and related files

[sdbt ~]# userdel jack

7. groupadd create a new group

[sdbt ~]# groupadd ssdbtt

8. groupmod modify a group definition on the system.

[sdbt ~]# groupmod -n sdbtsdbt ssdbtt

9. groupdel delete a group

[sdbt ~]# groupdel sdbtsdbt

10. Files related to linux user information

/etc/passwd – User account information.

/etc/shadow – Secure account information.

/etc/group – Group account information.

/etc/gshadow – Secure group account information.

/etc/login.defs – Shadow password suite configuration..EXIT VALUES

11. Fdisk -l hard disks can be divided into one or more logical disks called partitions

[sdbt ~]#fdisk –l
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0003bfc0
Device Boot Start End Blocks Id System
/dev/sda1 1 26109 209715200 83 Linux
/dev/sda2 26109 39163 104857600 83 Linux
/dev/sda3 39163 52217 104857600 83 Linux
/dev/sda4 52217 121602 557331160 5 Extended
/dev/sda5 52217 65272 104857600 83 Linux
/dev/sda6 65272 78326 104857600 83 Linux
/dev/sda7 78326 91380 104857600 83 Linux
/dev/sda8 91380 104434 104857600 83 Linux
/dev/sda9 104435 108351 31457280 82 Linux swap / Solaris
/dev/sda10 * 108351 121602 106436608 83 Linux

12. service network

Mostly used when we change network configuration like ipaddress

[sdbt ~]# service network start
Bringing up loopback interface: [ OK ] Bringing up interface Auto_Ethernet: Active connection state: activated
Active connection path: /org/freedesktop/Network
Manager/ActiveConnection/1 [ OK ] RTNETLINK answers: File exists

[sdbt ~]# [root@acs home]# service network restart
Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface Auto_Ethernet:
Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/2
[ OK ] [sdbt ~]# service network stop
Shutting down loopback interface: [ OK ]

13. Service iptables – related to firewall

service iptables stop #stop the iptables stop

chkconfig iptables off #chkconfig iptables off -> make this change to register in rc.d scripts.

#reboot the PXE server.
[sdbt ~]# service iptables stop
iptables: Setting chains to policy
ACCEPT: nat mangle filte[ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ]

[sdbt ~]# service iptables start
iptables: Applying firewall rules: [ OK ]

12. service network

Mostly used when we change network configuration like ipaddress

[sdbt ~]# service network start
Bringing up loopback interface: [ OK ] Bringing up interface Auto_Ethernet: Active connection state: activated
Active connection path: /org/freedesktop/Network
Manager/ActiveConnection/1 [ OK ] RTNETLINK answers: File exists

[sdbt ~]# [root@acs home]# service network restart
Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface Auto_Ethernet:
Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/2
[ OK ] [sdbt ~]# service network stop
Shutting down loopback interface: [ OK ]

14. scp – secure copy files from oner linux server to another linux server

[sdbt ~]$ scp [email protected]:scr.tar.gz [email protected]:scr200.tar.gz
[email protected]’s password:
[email protected]’s password:
scr.tar.gz 100% 4649 4.5KB/s 00:00 Connection to 192.168.1.200 closed.

14. ssh – ssh is a program for logging into a remote machine and for executing commands on a remote machine. ssh connects and logs into the specified hostname.

[sdbt ~]$ ssh [email protected]
[email protected]’s password:
Last login: Tue Jul 10 14:49:17 2018 from 192.168.1.250\
Server time : Tue Jul 10 16:09:57 IST 2018

15. ftp -> copy files from windows to linux server.

[sdbt ~]$ ftp
ftp>open sdbt.sdbtdomain.com
ftp>ls
ftp>dir
ftp>get
ftp>mget
ftp>put
ftp>mput
ftp>bye