Commands For Linux System Administration

PS : This page keeps on updating !


The startup and shutdown scripts are located in /etc/rc.d . These are usually used by root and used for system maintenance or emergency filesystem repairs. Use with caution, as some of these commands may damage your system.

Show all logged on users. This is the approximate equivalent of
# who -q

Shows all groups in the system
# groups
# echo $GROUPS

The chown command changes the ownership of a file or files. This command is a useful method that root can use to shift file ownership from one user to another.
# chown filename/dirname
# chown -R filename/dirname  // Appending the ownership to the child folders/files

The chgrp command changes the group ownership of a file or files
# chgrp filename/dirname

It adds a user account to the system and creates a home directory for that particular user
# useradd username

This command removes a user account from the system  and deletes associated files.
# userdel username
# userdel -r username // removes the home directory as well

Delete a group
# groupdel gpname

Creating a user and assign it to a group

# usermod -G <gp name> <user name>   // existing group and existing user
# useradd -G  <gp name> <user name>   //  existing group and new user

Modify/renaming a user account. Changes may be made to the password, group membership, expiration date, and other attributes of a given user's account. With this command, a user's password may be locked, which has the effect of disabling the account.
#usermod -l newname oldname

Modify a given group. The group name and/or ID number may be changed using this command.

It lists the real and effective user IDs and the group IDs of the user associated with the current process.

Creating/reset a password for user
# passwd username
Removing password for a user
# passwd -d username

Putting A Program In The Background
# &
[1] 1234

To view the background process
[2]+ &

Listing Your Processes
Display a list of the processes we have launched
# ps
121 pts/4 00:00:00 bash
226 pts/4 00:00:00
237 pts/4 00:00:00 ps

Killing A Process
Suppose that you have a program that becomes unresponsive,To identify the process you want to kill. You can use either jobs or ps. If you use jobs you will get back a job number.

# kill %1
# kill 226 // process id

How long your system is running and the number of users are currently logged in and also displays load average of the machine for 1,5 and 15 minutes intervals.

# uptime
08:16:26 up 22 min,  1 user,  load average: 0.00, 0.03, 0.22

Displays users currently logged in and their process along-with shows load averages. also shows the login name, tty name, remote host, login time, idle time, JCPU, PCPU, command and processes.

# w
08:12:00 up 55 min,  1 user,  load average: 0.00, 0.03, 0.08
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
vivek        pts/0     08:08       0.00s     0.29s    0.09s   w

Lists files and folders.

#ls           // Just display
#ls -ltr     // Sort file as per last modified time.

Used for task scheduling .

# crontab -e -u <username>
* * * * * mkdir /heloo
These five stars represents min,hour,day of month,month,day of week

#crontab -l     // to list
#crontab -e   // to edit

It helps quick view file. You can page up and page down to scrol. Press ‘q‘ to quit.

It helps to view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.

It is used to view single/multiple file at the same time.

#cat error.log access.log  
#cat apache.log | less     // with less command
#cat apache.log | more  // with more command

pwd (Present Working Directory)
It return with present working directory.


Free command shows free, total and swap memory information in bytes.

# free -m
                      total       used       free     shared    buffers     cached
Mem:         24020      13548      10471          0         43        666
-/+ buffers/cache:      12838      11182
Swap:         8191          0       8191

It displays processor activity of your system and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used. Press ‘q‘ to quit. [Task manager in windows]

Search for a given string in a file.

# grep vivek /etc/passwd

Search files, strings and directories.

# find / -name vivek

It Lists of all open files.

we can watch users login informations.

#last -n 10   // Displays last 10 users login details

For displaying ipaddress and its corresponding details

#ifconfig eth0 down                    // Disable an Interface
#ifconfig eth0 up                       // Enable an Interface
#ifconfig eth0  // Assign IP Address to an Interface
#ifconfig eth0 netmask          // Change Subnet Mask of Interface eth0
#ifconfig eth0 broadcast  // Change Broadcast Address of Interface eth0
#ifconfig eth0 netmask broadcast // Assign IP Address, Netmask and Broadcast to Interface eth0

netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, etc.....

#netstat -a       // List All Network Ports
#netstat -at    // List All TCP Ports
#netstat -s    // Show Statistics for All Ports


#nslookup                         //  Used to obtain for quering Domain Name System
#nslookup -query=mx     // Query Mail Exchanger Record
#nslookup -type=ns       // Query Name Server
#nslookup -type=any   // Query DNS Record
#nslookup -type=soa  // Query Start of Authority

Used for querying DNS name servers for information about host addresses, mail exchanges, name servers, and others.


It sends a message to everybody logged in the terminal.only if mesg permission set to "yes"

#wall "Hey !"

To control if people can use the “write” command, to send text to you over the screen.

#mesg y/n

Show users' total logged in time, as read from /var/log/wtmp
total     1764.94

Shows macines name

#hostname   // to view machine name
#hostname <new name>  //  to change hostname (temporary)
#vim /etc/sysconfig/network  // to change hostname field (permanent)

Network mapper and port scanner. This command scans a server to locate open ports and the services associated with those ports. It can also report information about packet filters and firewalls. This is an important security tool for locking down a network against hacking attempts.

Mount a filesystem, usually on an external device, such as a floppy or CDROM. The file /etc/fstab provides a handy listing of available filesystems, partitions, and devices, including options, that may be automatically or manually mounted.mount -a mounts all filesystems and partitions listed in /etc/fstab

# mount    // will display all mounted partitions

Example for manual mounting
mount /dev/cdrom /mnt                       //   mount cdrom to /mnt partition
Example for permanant mounting
vim /etc/fstab
/dev/hda7    /data   ext3  defaults 00   // mount hda7 to /data

# umount
To umount the drives.

# umount /dev/cdrom

Commands For Linux System Administration Commands For Linux System Administration Reviewed by vivek sathisan on 13:00 Rating: 5

No comments:

© Copyright to vivek sathisan. Powered by Blogger.