Useful Linux Commands for System Administrators

jmlopez

Member
Registered
Joined
Jul 11, 2016
Messages
24
Points
3
As a Linux administrator, you will need to know more commands to control your hosting server effectively. I would sum up some of the most basic commands required for sysadmins and webmasters. The command has been tested on CentOS 5 and 6 operating system.

1. The basic commands

Code:
# ls // like dir command in windows
# vi // open the text editor 
# passwd // change the current user password
# chmod // grant permissions for folders and files 
# chgrp //change group for folders and files
# chown // change the directory and file owner
# cp a b // copy a file into the folder b
# reboot // reboot the system //
# shutdown -h now // shutdown system (shutdown)
# shutdown -r now // shutdown system (restart)
2. Networking (limited use when in remote mode)

Code:
# ifconfig // view and config ip of server
# setup // select Network Configuration to set IP for server
# vi /etc/resolv.conf // configure dns for server
# ifdown eht0 // down network card eth0
# ifup eht0 // up network card eth0
# service network restart // restart network service
3. Check System

Code:
# top // whether the resource usage of RAM, the system's CPU
# uptime // average view the status of the system and the system was online time
# fdisk -l // see the HDD on server
# df -h // check usage HDD
# cat /proc/cpuinfo // Check CPU
# cat /proc/meminfo // Check RAM ussage
# du -hs // check folder usage
4. Webserver and MySQL

Code:
# service httpd status // view webserver status
# service httpd restart // restart  webserver
# service mysqld restart // restart mysql
# mysqlcheck -Aao -auto-repair -u[MySqlAdmin] -p[Password] // check and optimize mysql database
5. Zip and unzip

Code:
# tar -cvzpf archive.tgz /home/example/public_html/folder // compress a folder
# tar -tzf backup.tar.gz // list gz files
# tar -xvf archive.tar // decompress a tar file
If you have any other useful commands for Linux, please write down and I appreciate that.

Hope it helps!
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
Very good thread, it will be useful for beginners.

Some commands you could also use :

Use the good argument for ls. -a for all, -l for list it's easier to read, -h for human readable and I'm sure you prefer to read 512M than 536870912 B.
Code:
ls -alh
Update your server in a single command on debian/ubuntu
Code:
 apt-get update && apt-get update -y
rename a file
Code:
mv yourfileoldname yourfilenewname
and move a file
Code:
mv yourfile /var/www/yourfilemoved
if you have a zip to extract
Code:
apt-get install unzip
unzip yourfile.zip
if you don't love vi, go with nano
Code:
nano myfile.txt
 

liveinhost

Member
Hosting Provider
Registered
Joined
Jan 18, 2017
Messages
48
Points
8
Thank you for the information. This thread will help to learn new things for beginners.
 

Robert Plummer

Member
Registered
Joined
Feb 23, 2017
Messages
26
Points
3
RedHat/CentOS

Let's not forget RedHat/CentOS based systems...

Update pacakges on RHEL/CentOS
Code:
# yum upgrade
If there are pacakge dependency issues and you just want to get the ones that are patchable right now
Code:
# yum upgrade --skip-broken
On CentOS 7.x we use SystemCTL instead of Service
Code:
//status
# systemctl status httpd
//restart
# systemctl restart httpd
//stop
# systemctl stop httpd
//start
# systemctl start httpd
++++1 for the use of Nano/Pico over vi/vim for beginners. There is much steeper learning curve for vi/vim, but as you progress you should learn how to use it, as it's installed almost everywhere in unix/linux by default and pico/nano is not.
 

HostingWaves

Member
Registered
Joined
Jan 16, 2017
Messages
53
Points
0
Its really good thread for newby.

If you are on CentOS 7 then you will need to use command 'ip addr' to check IP address on the server.
 
Recommended Threads
Replies
3
Views
2,805
Replies
3
Views
2,841
Replies
6
Views
2,711
Similar Threads
Replies
2
Views
2,180
Replies
9
Views
3,704
Replies
8
Views
2,952
Replies
10
Views
5,514

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top