Linux System Admin Commands

Linux Server IP Important Commands

hostnamectl command

How to change the Hostname

[root@Sharique ~]# hostnamectl status

Once change the hostname need to restart Linux Server.

[root@Sharique ~]# hostnamectl set-hostname qp

So here you can check the hostname has been changed.

[root@qp ~]# hostnamectl status

[root@qp ~]# hostname

How to change the centos/RedHat Linux  etc/hosts and host IP address.

Now here I am using centos-8 if you will check there is only old version or other Linux difference in directory.

Centos/RedHat Linux

 /etc/sysconfig/network-scripts/ifcfg-eth0

Ubuntu

/etc/netplan/00-installer-config.yaml

[root@qp ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

Or

[root@qp ~]# nano /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33P96-98f8-48664244bff9
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.60.49
PREFIX=24
GATEWAY=192.168.60.1
DNS1=192.168.60.2
DOMAIN=querypanel.local
IPV6_PRIVACY=no

After applying the new IP address need to restart the Network.

systemctl start NetworkManager.service

[root@qp ~]# systemctl stop NetworkManager.service

[root@qp ~]# systemctl start NetworkManager.service

[root@qp ~]# systemctl Restart NetworkManager.service

[root@qp ~]# systemctl status NetworkManager.service

Using nmcli Tool

The nmcli is the command-line utility for the managing NetworkManager on CentOS/RHEL 8 Linux system. You can simply use this utility to stop/start network service on your CentOS 8 or RHEL 8 system.

WARNING – Do not run nmcli networking off for the remotely connected systems. This will disable the NetworkManager network connections on the machine and you will lose connection.

[root@qp ~]# sudo nmcli networking off

[root@qp ~]# nmcli general status

[root@qp ~]# nmcli networking on

How do we check mysql and Apache Server Running status.

Here: step by steps methods.

[root@qp ~]# systemctl status httpd

[root@qp ~]# systemctl status httpd.service

[root@qp ~]# systemctl restart httpd

[root@qp ~]# systemctl start httpd

[root@qp ~]# systemctl stop httpd

[root@qp ~]# systemctl status mysqld

[root@qp ~]# systemctl restart mysqld

CommandFunction
manDisplay information about all commands
uptimeShow how long system is running
usersShow username who are currently logged in
serviceCall and execute script
pkillKill a process
pmapMemory map of a process
wgetDownload file from network
ftp or sftpConnect remote ftp host
freeShow memory status
topDisplay processor activity of system
lastDisplay user’s activity in the system
psDisplay about processes running on the system
Shutdown commandsShutdown and reboot system
infoDisplay information about given command
envDisplay environment variable for currently logged-in user
netstatDisplay network status
arpCheck ethernet connectivity and IP address
dfDisplay filesystem information
duDisplay usage
initAllow to change server bootup
nanoA command line editor
nslookupCheck domain name and IP information
shredDelete a file by over writing its content
catDisplay, copy or combine text files
pwd>Print path of current working directory
locateFinding files by name on system
chownChange ownership of a file
>aliasTo short a command
echoDisplay text
cmpCompare two files byte by byte
mountMount a filesystem
ifconfigDisplay configuration
traceroute>Trace existing network
sudoRun a command as a root user
routeList routing table for your server
pingCheck connection by sending packet test packet
findFind location of files/directories
usersShow current logged in user
whoSame as w but doesn’t show current process
lsList all the files
tarCompress directories
grepSearch for a string in a file
suSwitch from one to another user
awkSearch lines for a given pattern

shariq@unv:~$ man uptime

shariq@unv:~$ man users

shariq@unv:~$ man service

shariq@unv:~$ man pkill

shariq@unv:~$ man pmap

One thought on “Linux System Admin Commands

  • August 21, 2022 at 1:45 pm
    Permalink

    Merely wanna remark that you have a very nice website , I love the design it really stands out.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *