Linux Command Line Reference

5/9/2012 Md. Azaj Ikbal (RHCSA, RHCE) E-mail:

Execute commands at a later time [root@rhel6 ~]# at -f myscript.Manipulate the system ARP cache [root@rhel6 ~]# arp bc .An arbitrary precision calculator language [root@rhel6 ~]# bc bzip2 . Azaj Ikbal(RHCE). If you know these basic Linux 2:50 friday arp . because you will hardly allowed using GUI. All rights are reserved. So use the command line as much as possible. To be a system administrator you need to know how to manage the server using command line. Page 2 . The color code of the files is as follows: Blue: Directory file White: Normal file Green: Executable file Yellow: Device file Magenta: Picture file Cyan: link file Red: Compressed file Linux File (Types) . Basic Linux Commands and there explanation is given below: at .A file compression utility.Displays a calendar [root@rhel6 ~]# cal 2012 cat . [root@rhel6 ~]# bzip2 file2 cal . Because most of the system administration tasks are managed remotely using the secure shell also known as SSH.Concatenate and print files Prepared by: Md.= Normal file (Hypen) d=directory l =Link file b=Block device file c=Character device file s= Socket File p=Pipe File .) are a hidden file. These commands are common in most common Linux distributions.To start-up with the Linux first someone needs to know about the basic Linux commands. = Hidden Files starting with a dot (. it will be easy for you to get further in your goal to achieve a Red Hat Certification.

Report file system (Linux) disk space usage Prepared by: Md.With no option will changes to the home directory.updates and queries runlevel information for system services [root@rhel6 ~]# chkconfig vsftpd on chmod .Will change one level up in the directory tree. Azaj Ikbal(RHCE). All rights are reserved. cd – .Print selected parts of lines [root@rhel6 ~]# cut -d : -f 1 /etc/passwd date . ..Clear the terminal screen [root@rhel6 ~]# clear cp .Ext2/ext3/ext4 file system debugger [root@rhel6 ~]# debugfs -w /dev/sda2 df .Will change to the root (/) directory cd .Print or set the system date and time [root@rhel6 ~]# date [root@rhel6 ~]# date -s "2 JUN 2012 18:00:00" debugfs .Set schedule periodic background work [root@rhel6 ~]# crontab -e cut .Change group ownership [root@fileserver ~]# chgrep sales file2 chkconfig .[root@fileserver ~]# cat /etc/passwd cd . Page 3 . cd / .Copy files and directories [root@rhel6 ~]# cp /etc/passwd /home/robi crontab ..Change file access permissions [root@rhel6 ~]# chmod 740 file10 chown .Change user password expiry information [root@rhel6 ~]# chage -E "2012-06-31" robi chgrp .Will back to previous directory [root@rhel6 [root@rhel6 [root@rhel6 [root@rhel6 ~]# ~]# ~]# ~]# cd cd / cd cd . chage .Change file owner and group [root@rhel6 ~]# chown robi file11 clear .

Display a line of text [root@rhel6 ~]# echo cslit training edquota .Estimate file space usage [root@rhel6 ~]# du -ch filename e2label .com dir .name [what to find] finger .Free allocated memory [root@rhel6 ~]# free -m fsck .Print or control the kernel ring buffer [root@rhel6 ~]# dmesg | less [root@rhel6 ~]# dmesg | grep hd dnsdomainname .Check and repair a Linux file system [root@rhel6 ~]# fsck. Page 4 .Edit user quotas [root@rhel6 ~]# edquota robi eject .Open and closed removable media [root@rhel6 ~]# eject [root@rhel6 ~]# eject -t fdisk .User information lookup program [root@rhel6 ~]# finger rani free .Partition table manipulator for Linux [root@rhel6 ~]# fdisk -l find .[root@rhel6 ~]# df -HT diff .List directory contents [root@rhel6 ~]# dir linux1 dmesg . Azaj Ikbal(RHCE).DNS lookup utility [root@rhel6 ~]# dig ns1.Change the label on an ext2/ext3/ext4 filesystem [root@rhel6 ~]#e2label /dev/sda11 mylinux echo .Find differences between two files [root@rhel6 ~]# diff file1 file2 dig .cslitbd. All rights are reserved.Show the system's DNS domain name [root@rhel6 ~]# dnsdomainname du .ext4 /dev/sda11 Prepared by: Md.Search for files in a directory hierarchy [root@rhel6 ~]# find [where to find] .

The GNU version of the awk text processing utility.Print lines matching a pattern [root@rhel6 ~]# cat /etc/passwd | grep robi groupadd .254 gawk .Stop the system [root@rhel6 ~]# halt head .Show or set the system's host name [root@rhel6 ~]# hostname [root@rhel6 ~]# hostname gateway history .gz halt .sumon sales grep .robi.Show and delete all command history [root@rhel6 ~]# history [root@rhel6 ~]# histoy -c id .11.View and configure a network interface [root@server ~]# ifconfig Prepared by: Md.tar.Modify a group [root@rhel6 ~]# groupmod -n airtel warid gunzip.gz [root@rhel6 ~]# gzip file. Page 5 sales .Print user identity [root@rhel6 ~]# id robi ifconfig . All rights are reserved.Compress or expand files [root@rhel6 ~]# gunzip file.Output the first 10 line of file [root@rhel6 ~]# head /etc/passwd host .Administer the /etc/group file [root@rhel6 ~]# gpasswd -M rani. gzip .cslitbd. [root@rhel6 ~]# ps aux > processes [root@rhel6 ~]# gawk '{print $1$2$3$4}' processes gpasswd .Internet file transfer program [root@rhel6 ~]# ftp 192.Delete a group [root@rhel6 ~]# groupdel groupmod .168. Azaj Ikbal(RHCE).ftp .DNS lookup utility [root@rhel6 ~]# host hostname .Create a new group [root@rhel6 ~]# groupadd sales groupdel .

11.A stand alone TTY based reader for GNU texinfo documentation. [root@server ~]# info passwd init.Make links between files [root@rhel6 ~]# ln -s file1 /linux/file2 [root@rhel6 ~]# ln file10 /linux/file20 lpq .Show listing of last logged in users [root@rhel6 ~]# last lastb .Reports the most recent login of all users or of a given user [root@rhel6 ~]# lastlog less .Cancel print jobs [root@rhel6 ~]# lprm Prepared by: Md.255.Tools for managing Linux kernel packet filtering capabilities.Terminate a process killall kill processes by name [root@server ~]# killall -9 firefox [root@server ~]# kill -9 firefox last .Show listing of last logged in users [root@rhel6 ~]# lastb lastlog .[root@server ~]# ifconfig eth0 [root@server ~]# ifconfig eth0 192. [root@server ~]# iptables -L [root@server ~]# ifconfig -F [root@server ~]# service iptables restart kill .0 up [root@server ~]# ifconfig eth0 192.254 255. telinit .Print files [root@rhel6 ~]# lpr lprm . Azaj Ikbal(RHCE).255.255.Link to a file [root@rhel6 ~]# link -s file1 /linux/file2 [root@rhel6 ~]# link -s file10 /linux/file20 ln .Show printer queue status [root@rhel6 ~]# lpq lpr .Opposite of more [root@rhel6 ~]# cat /etc/passwd | less link .Process control initialization [root@server ~]# init 6 [root@server ~]# telinit 5 iptables . All rights are reserved. Page 6 . 255.255.0 down info .

All rights are reserved.List directory contents [root@server [root@server [root@server [root@server ~]# ~]# ~]# ~]# ls ls -l ls -la ls -lih lspci .cf mail . manipulate media-independent interface status [root@rhel6 ~]# mii-tool eth0 mkdir .lpstat .Format and display the on line manual pages [root@rhel6 ~]# man ifconfig mii-tool . [root@rhel6 ~]# m4 sendmail. Azaj Ikbal(RHCE).Program to show the status of modules in the Linux Kernel [root@rhel6 ~]# lsmod | less lsusb .GNU make utility to maintain groups of programs [root@rhel6 [root@rhel6 [root@rhel6 [root@rhel6 [root@rhel6 ~]# make menuconfig ~]#make gconfig ~]# make ~]# make modules ~]# make modules_install man .mc > /etc/sendmail.Find files by name [root@rhel6 ~]# locate passwd ls ."Hello" boss@cslitbd.List USB devices [root@rhel6 ~]# lsusb m4 .Make directories [root@rhel6 [root@rhel6 [root@rhel6 [root@rhel6 ~]# ~]# ~]# ~]# mkdir mkdir mkdir mkdir training /cslit/training/linux -p class11 class12 class13 /class{ make . .Print the mail queue [root@rhel6 ~]# mail .8} Page 7 Prepared by: Md.List all PCI devices [root@rhel6 ~]# lspci lsmod .7.6.The GNU macro processor.View.Send and receive mail [root@rhel6 ~]# mailq mailq .Print cups status information [root@rhel6 ~]# lpstat locate .

Inform the OS of partition table changes [root@rhel6 ~]# partprobe /dev/sda ping .8} mke2fs .Create an MS DOS file system under Linux [root@rhel6 ~]# mkdir /class{5.Build a Linux file system [root@rhel6 ~]# mkfs.Print network connections [root@rhel6 ~]# netstat -nplr newaliases .Change to a new group nslookup .ext4 /dev/sda10 mkisofs .168.Move (rename) files [root@rhel6 ~]# mv file10 file20 netstat .iso -v -R /directory mkswap .mkdosfs .7.cslitbd.Creates an image of an ISO9660 filesystem.11.Send ICMP ECHO_REQUEST to network hosts Prepared by: Md. [root@rhel6 ~]# mkisofs -o image.Mount a file system [root@server [root@server [root@server [root@server ~]# ~]# ~]# ~]# mount mount mount mount /dev/dvd /mnt /dev/sdb1 /media -t vfat /dev/sda12 /software -t nfs 192.Query Internet name servers interactively [root@rhel6 ~]# nslookup ns1.254:/share/rpm /myshare mv . Azaj Ikbal(RHCE).6. Page 8 .Create an ext2/ext3 file system [root@rhel6 ~]# mke2fs -j /dev/sda12 mkfs .com passwd . All rights are reserved.File perusal filter for crt viewing [root@rhel6 ~]# cat /etc/passwd | more mount .Rebuild the data base for the mail aliases file [root@rhel6 ~]# newaliases newgrp .Set up a Linux swap area [root@rhel6 ~]# mkswap /dev/sda11 modprobe .Update a user’s authentication tokens(s) [root@rhel6 ~]# passwd robi partprobe .Add and remove modules from the Linux Kernel [root@rhel6 ~]# modprobe your-kernel-module more .

254 poweroff .11.Display disk usage and limits [root@rhel6 ~]# quota quotacheck . check and repair [root@rhel6 ~]# quotacheck -avug quotaon .File system resizer [root@rhel6 ~]# resize2fs /dev/sda1 6000M rm .Summarize quotas for a filesystem [root@rhel6 ~]# repquota /quota [root@rhel6 ~]# repquota -g /quota reset . create.cslitbd.Display a tree of processes [root@rhel6 ~]# pstree pwd .Stop the system [root@rhel6 ~]# poweroff ps . All rights are reserved.Scan a filesystem for disk usage.Terminal initialization [root@rhel6 ~]# reset resize2fs .Turn filesystem quotas on and off [root@rhel6 ~]# quotaoff -auvg reboot . Page 9 .Turn filesystem quotas on and off [root@rhel6 ~]# quotaon /quota quotaoff .Remove files or directories [root@rhel6 ~]# rm -r mydocument rmdir .Print name of current/working directory [root@rhel6 ~]# pwd quota .Alter priority of running processes [root@rhel6 ~]# renice 5 -p 13220 repquota .Reboot or enable or disable Ctrl-Alt-Del [root@rhel6 ~]# reboot renice .Report a snapshot of the current processes [root@rhel6 ~]# ps -aux | more pstree . Azaj Ikbal(RHCE) [root@rhel6 ~]# ping 192.[root@rhel6 ~]# ping ns1.Remove empty directories [root@rhel6 ~]# rmdir linuxdoc Prepared by: Md.

i386.Start/stop swapping to file/device [root@rhel6 ~]# swapoff -a swapon .ikbal sudo . [root@rhel6 ~]# ssh -P 2212 robi@192.254 [root@rhel6 ~]# ssh -p 2212 192.*/\1/' /etc/passwd setquota .168.11.168.Run a shell with substitute user and group IDs [root@rhel6 ~]# su – [root@rhel6 ~]# su .11.OpenSSH SSH client [root@rhel6 ~]# ssh 192.254 su .2.16811.11.A program for synchronizing files over a network.11.10-5. Page 10 .Set disk quotas [root@rhel6 ~]# setquota -g quotagrp 5 100 6 10 -a /dev/loop0 sftp .Enable/disable devices and files for paging and swapping Prepared by: Md. Azaj Ikbal(RHCE).txt nazrul@server:/home/mydoc scp .00 –c ssh . All rights are showmount .Secure file transfer program [root@rhel6 ~]# sftp nazrul@cslitbd.RPM Package Manager [root@server ~]# rpm -qa | grep vsftpd [root@server ~]# rpm -ivh vsftpd.Secure copy (remote file copy program) [root@rhel6 ~]# rsync -avz ikbal@192.rpm rsync . [root@rhel6 ~]# scp /home/ikbal/data.12 shutdown .A GNU stream text editor [root@rhel6 ~]# sed 's/\([^:]*\).Execute a command as another user [robin@rhel6 ~]$ sudo mount /dev/sda3 /mnt swapoff .Bring the system down [root@rhel6 [root@rhel6 [root@rhel6 [root@rhel6 [root@rhel6 ~]# ~]# ~]# ~]# ~]# shutdown shutdown shutdown shutdown shutdown –r now –h now –r 20:00 –h 20.10:/home/rpm /root/backup sed .Manipulate the IP routing table [root@rhel6 ~]# route -n rpm .Show mount information for an NFS server [root@rhel6 ~]# showmount -e 192.el5.route .

Azaj Ikbal(RHCE).[root@rhel6 ~]# swapon /dev/sdc1 tail .Dump traffic on a network [root@rhel6 ~]# tcpdump -i eth1 telnet .Output the last part of files [root@rhel6 ~]# tail –n 5 /etc/passwd tar .Tell how long the system has been running [root@rhel6 ~]# uptime useradd .User interface to the TELNET protocol [root@rhel6 ~]# telnet 192.Display Linux tasks [root@rhel6 ~]# top touch .Delete a user account and related files [root@rhel6 ~]# userdel robi Prepared by: Md.cslitbd. Page 11 .The GNU version of the tar archiving utility [root@rhel6 ~]# tar filename.Adjust tunable filesystem parameters [root@rhel6 ~]# tune2fs -L usbstroage /dev/sdb2 umount .com tty .168.Unmount file systems [root@rhel6 ~]# umount /dev/sdb1 [root@rhel6 ~]# umount /mnt uname .Print the file name of the terminal [root@rhel6 ~]# tty tune2fs .Change file timestamps [root@rhel6 ~]# touch fil1 [root@rhel6 ~]# touch /linux/lesson{1.Create a new user or update default new user information [root@rhel6 ~]# useradd robi [root@rhel6 ~]# useradd -G samba rani userdel .Traces the route packets over an IPv4/IPv6 network [root@rhel6 ~]# traceroute www.tar filename tcpdump .254 top . All rights are reserved.3} traceroute .2.11.Print system information uname .r -Linux kernel information [root@rhel6 ~]# uname [root@rhel6 ~]# uname -r uptime .

com/tutorial_pdf/Linux/NAT.Print the user names of users currently logged in to the current host [root@rhel6 ~]# users Vi/vim .Linux text editor [root@rhel6 ~]# vi oldfile [root@rhel6 ~]# vim newfile vmstat .Show who is logged on [root@file ~]# who whoami .Yellowdog Updater Modified [root@file ~]# yum install samba* -y [root@file ~]# yum remove samba* The End Prepared by: Md.Print effective userid [root@file ~]# whoami yum . and manual page files for a command [root@file ~]# whereis bash which .Word.Show who is logged on and what they are doing [root@file ~]# w wc .pdf whatis . and byte or character count [root@file ~]# wc file11 wget .Shows the full path of (shell) commands [root@file ~]# which adduser who . Azaj Ikbal(RHCE). [root@file ~]# wget http://www.Locate the binary.cslitbd. All rights are reserved. source. Page 12 .Report virtual memory statistics [root@file ~]# vmstat -S M w .Search the whatis database for complete words [root@file ~]# whatis useradd whereis . line.[root@rhel6 ~]# userdel -r rani usermod .Modify a user account [root@rhel6 ~]# usermod -G media joy users .A utility for retrieving files using the HTTP or FTP protocols.

Page 13 . Azaj Ikbal(RHCE). All rights are reserved.Prepared by: Md.

Sign up to vote on this title
UsefulNot useful