PDF Bash Commands DD
PDF Bash Commands DD
ddrescue Data
ddrescue
declare
declare Data recovery
Declare tooland give them attributes •
variables
df
df
Display free disk space
diff
diff Display the differences between two files
diff3
diff3
Show differences among three files
dig
dig DNS lookup
dir
dir
Briefly list directory contents
dircolors
dircolors Colour
Colour setup for `ls'
dirname
dirname Convert a full
full pathname to just
just a path
dirs
dirs
Display list of remembered directories
dmesg
dmesg Print kernel & driver messages
du
du Estimate file space usage
e
echo
echo Display message on screen •
egrep
egrep
Search file(s) for lines that match an extended
expression
eject
eject Eject removable media
enable
enable Enable and disable builtin shell commands •
env
env
Environment variables
ethtool Ethernet card settings
eval
eval
Evaluate several commands/arguments
exec
exec Execute a command
exit
exit
Exit the shell
expect
expect Automate arbitrary applications accessed over a
terminal
expand
expand Convert tabs to spaces
export
export Set an environment variable
expr
expr
Evaluate expressions
f
false
false
Do nothing, unsuccessfully
fdformat Low-level
fdformat Low-level format a floppy disk
fdisk
fdisk
Partition table manipulator for Linux
fg
fg Send job to foreground
fgrep
fgrep Search file(s) for lines that match a fixed string
file
file
Determine file type
find
find
Search for files that meet a desired criteria
fmt
fmt Reformat paragraph text
fold
fold
Wrap text to fit a specified width.
for
for Expand words, and execute commands
format Format disks or tapes
free Display memory usage
fsck
fsck File system consistency check and repair
ftp File Transfer Protocol
function
function Define
Define Function Macros
fuser
fuser
Identify/kill the process that is accessing a file
g
gawk
gawk Find and Replace text within file(s)
getopts
getopts Parse positional parameters
grep
grep
Search file(s) for lines that match a given pattern
groupadd
groupadd Add
Add a user security group
groupdel Delete
groupdel Delete a group
groupmod
groupmod Modify
Modify a group
groups
groups Print group names a user is in
gzip
gzip Compress or decompress named file(s)
h
hash
hash Remember the full pathname of a name argument
head
head Output the first part of file(s)
help Display help for a built-in command •
history
history Command History
hostname Print
hostname Print or set system name
i
iconv
iconv
Convert the character set of a file
id
id Print user and group id's
if
if Conditionally perform a command
ifconfig Configure
ifconfig Configure a network interface
ifdown
ifdown Stop a network interface
ifup
ifup Start a network interface up
import Capture an X server screen and save the image to file
import
install
install Copy files and set attributes
j
jobs
jobs
List active jobs •
join
join Join lines on a common field
k
kill
kill
Stop a process from running
killall Kill processes by name
killall
l
less
less
Display output one screen at a time
let
let Perform arithmetic on shell variables •
link
link Create a link to a file
ln
ln Create a symbolic link to a file
local
local Create variables •
locate
locate Find files
logname
logname Print current login name
logout
logout Exit a login shell •
look
look Display lines beginning with a given string
lpc
lpc Line printer control program
lpr
lpr
Off line print
lprint Print a file
lprintd Abort a print job
lprintq List the print queue
lprm
lprm Remove jobs from the print queue
ls
ls
List information about file(s)
lsof
lsof List open files
m
make Recompile a group of programs
man
man
Help manual
mkdir
mkdir
Create new folder(s)
mkfifo
mkfifo Make FIFOs (named pipes)
mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem
mknod
mknod
Make block or character special files
more
more Display output one screen at a time
most
most
Browse or page through a text file
mount
mount Mount a file system
mtools
mtools Manipulate MS-DOS files
mtr
mtr Network diagnostics (traceroute/ping)
mv
mv Move or rename files or directories
mmv
mmv Mass Move and rename (files)
n
netstat Networking information
nice
nice Set the priority of a command or job
nl
nl
Number lines and write files
nohup
nohup
Run a command immune to hangups
notify-send
notify-send Send desktop notifications
nslookup
nslookup Query
Query Internet name servers interactively
o
open
open Open a file in its default application
op
op Operator access
p
passwd
passwd Modify a user password
paste
paste Merge lines of files
pathchk Check file name portability
ping
ping Test a network connection
pkill
pkill
Stop processes from running
popd
popd Restore the previous value of the current directory
pr
pr
Prepare files for printing
printcap Printer capability database
printenv Print environment variables
printf
printf Format and print data •
ps
ps Process status
pushd
pushd Save and then change the current directory
pv
pv Monitor the progress of data through a pipe
pwd
pwd Print Working Directory
q
quota
quota Display disk usage and limits
quotacheck Scan a file system for disk usage
quotacheck Scan
quotactl Set
quotactl Set disk quotas
r
ram
ram
ram disk device
rcp
rcp
Copy files between two machines
read
read Read a line from standard input •
readarray Read from stdin into an array variable •
readonly Mark variables/functions as readonly
readonly Mark
reboot Reboot the system
rename
rename Rename files
renice Alter priority of running processes
remsync Synchronize remote files via email
return
return Exit a shell function
rev
rev Reverse lines of a file
rm
rm
Remove files
rmdir
rmdir Remove folder(s)
rsync
rsync Remote file copy (Synchronize file trees)
s
screen
screen Multiplex terminal, run remote shells via ssh
scp
scp Secure copy (remote file copy)
sdiff
sdiff
Merge two files interactively
sed
sed
Stream Editor
select
select Accept keyboard input
seq
seq
Print numeric sequences
set
set Manipulate shell variables and functions
sftp Secure File Transfer Program
shift
shift
Shift positional parameters
shopt
shopt Shell Options
shutdown Shutdown
shutdown Shutdown or restart linux
sleep
sleep
Delay for a specified time
slocate
slocate Find files
sort
sort Sort text files
source
source Run commands from a file '.'
split
split Split a file into fixed-size pieces
ssh
ssh Secure Shell client (remote login program)
stat
stat
Display file or file system status
strace
strace Trace system calls and signals
su
su Substitute user identity
sudo
sudo
Execute a command as another user
sum
sum Print a checksum for a file
suspend
suspend Suspend execution of this shell •
sync
sync
Synchronize data on disk with memory
t
tail
tail
Output the last part of file
tar
tar Store, list or extract files in an archive
tee
tee Redirect output to multiple files
test
test
Evaluate a conditional expression
time
time
Measure Program running time
timeout
timeout Run a command with a time limit
times
times
User and system times
touch
touch Change file timestamps
top
top List processes running on the system
traceroute Trace
traceroute Trace Route to Host
trap Run a command when a signal is set(bourne)
tr
tr
Translate, squeeze, and/or delete characters
true
true Do nothing, successfully
tsort
tsort
Topological sort
tty
tty Print filename of terminal on stdin
type
type Describe a command •
u
ulimit
ulimit Limit user resources •
umask
umask
Users file creation mask
umount Unmount a device
unalias Remove an alias •
unalias
uname
uname
Print system information
unexpand Convert
unexpand Convert spaces to tabs
uniq
uniq Uniquify files
units
units
Convert units from one scale to another
unset
unset Remove variable or function names
unshar
unshar Unpack shell archive scripts
until
until Execute commands (until error)
uptime Show uptime
useradd Create new user account
useradd
userdel
userdel Delete a user account
usermod
usermod Modify user account
users
users
List users currently logged in
uuencode Encode a binary file
uuencode Encode
uudecode Decode
uudecode Decode a file created by uuencode
v
v Verbosely list directory contents (`ls -l -b')
vdir Verbosely list directory contents (`ls -l -b')
vi
vi Text Editor
vmstat
vmstat Report virtual memory statistics
w
wait
wait Wait for a process to complete •
watch
watch
Execute/display a program periodically
wc
wc Print byte, word, and line counts
whereis
whereis Search the
the user's
user's $path, man pages and source files
for a program
which
which
Search the user's $path for a program file
while
while Execute commands
who
who Print all usernames currently logged in
whoami
whoami Print the current user id and name (`id -un')
wget Retrieve web pages or files via HTTP, HTTPS or FTP
write
write
Send a message to another user
x
xargs
xargs Execute utility, passing constructed argument list(s)
xdg-open Open
xdg-open Open a file or URL in the user's preferred
application.
yes
yes Print a string until interrupted
zip
zip
Package and compress (archive) files.
. Run a command script in the current shell
!!
!! Run the last command again
###
###
Comment / Remark
The first column is the permissions of each file. if it begins with a - it is a normal file, if it begins with a d,
then it is a directory i.e. a folder containing other files or folders.
a - all
and x is the execute permission. If there is a hyphen (- ( -) in the place of one of these letters it means the
permission is not granted, and if the letter is present then it is granted.
Folders
r (read)
(read) stands for the ability to read the table of contents of the given directory,
w (write) stands for the ability to write the table of contents of the given directory (create new files,
folders; rename, delete existing files, folders) if and only if execute
execute bit is set. Otherwise this
permission is meaningless.
x (execute) stands for the ability to enter the given directory with command cd and access files,
folders in that directory.
total 176
-rw-r--r--.
-rw-------. 1
1 root
root root
root 683
1586 Aug
Jul 19
31 09:59
02:17 0001.pcap
anaconda-ks.cfg
anaconda-ks. cfg
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-r--r--. 1 root root 11439 Jul 31 02:13
install.log.syslog
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
3. View Hidden Files
List all files including hidden file starting with ‘.
‘.‘.
# ls -a
0001.pcap
.kde .config
.opera .elinks .spice-vdagent
.gnome2_private
.gnome2_priv
.spice-vdag ent ate
anaconda-ks.cfg
anaconda-ks.cfg .cshrc .esd_auth .gtk-bookmarks
.gtk-bookmarks
.libreoffice
.libreoffice Pictures .tcshrc
.bash_history
.bash_histor y .dbus .fbcmd .gvfs
.local .pki Templates
.bash_logout
.bash_logout Desktop fbcmd_update
fbcmd_update.php
.php .ICEauthori
.ICEauthority
ty
.mozilla Public Videos
.bash_profil
.bash_profile
Music e .digrc
.pulse .gconf .wiresharkindex.html
4. List Files with Human Readable Format with option -lh
With combination of -lh
-lh option,
option, shows sizes in human readable format.
# ls -lh
total 176K
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
-rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents
drwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads
-rw-r--r--. 1 root root 21K Aug 12 12:42 fbcmd_update.php
fbcmd_update .php
-rw-r--r--. 1 root root 46K Jul 31 09:58 index.html
-rw-r--r--. 1 root root 48K Jul 31 02:17 install.log
-rw-r--r--. 1 root root 12K Jul 31 02:13
install.log.syslog
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Videos
5. List Files and Directories with ‘/’ Character at the end
Using -F
-F option
option with ls
ls command,
command, will add the ‘/’
‘/’ Character
Character at the end each directory.
# ls -F
ls -R option
# -R
ls option
-R will list very long listing directory trees. See an example of output of the command.
total 1384
-rw-------. 1 root root 33408 Aug 8 17:25
anaconda.log
-rw-------. 1 root root 30508 Aug 8 17:25
anaconda.program.log
./httpd:
total 132
-rw-r--r-- 1 root root 0 Aug 19 03:14 access_log
-rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-
20120812
./lighttpd:
total 68
-rw-r--r-- 1 lighttpd lighttpd 7858 Aug 21 15:26
access.log
-rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21
access.log-20120819
./nginx:
total 12
-rw-r--r--. 1 root root 0 Aug 12 03:17 access.log
-rw-r--r--. 1 root root 390 Aug 12 03:17 access.log-
20120812.gz
8. Reverse Output Order
With combination of -ltr will
will shows latest modification
modification file or directory date as last.
# ls -ltr
total 176
-rw-r--r--. 1 root root 11439 Jul 31 02:13
install.log.syslog
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
anaconda-ks. cfg
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
-rw-r--r--. 1
-rw-r--r--. 1 root
root root
root 21262
46701 Aug
Jul 12
31 12:42
09:58 fbcmd_update.php
index.html
drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
9. Sort Files by File Size
With combination of -lS
-lS displays
displays file size in order, will display big in size first.
# ls -lS
total 176
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
-rw-r--r--. 1 root root 11439 Jul 31 02:13
install.log.syslog
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
-rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
anaconda-ks. cfg
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
10. Display Inode number of File or Directory
We can see some number printed before file /
file / directory
directory name. With -i
-i options
options list file /
file /directory
directory with
inode number.
# ls -i
total 36
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Downloads
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Music
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Pictures
-rw-rw-r--. 1 500 500 12 Aug 21 13:06 tmp.txt
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Videos
15. ls command and it’s Aliases
We have made alias for ls ls command,
command, when we execute ls command it’ll take -l
-l option
option by default and
display long listing as mentioned earlier.
# alias ls="ls -l"
Note: We can see number of alias available in your system with below alias command and same
Note:
can be unalias as shown below example.
# alias