Wednesday, May 1, 2013

BASIC LINUX COMMANDS WITH MAN PAGES


Here are some basic commands to get you started in the wonderful world of Linux and other UNIX variants. All of these commands should work from your command prompt (regardless which shell you’re using).You MUST press enter to invoke the command.All UNIX and Linux commands are case sensitive. There are of course thousands of Linux related commands and procedures.



You can also execute multiple commands by separating each one with a ; for example cd newdir; mkdir thatdir ; ls -la will first change directories to the newdir directory, then create a directory called thatdir, then list all the files in long format. You can string together as many commands as you like but caution should be used not to inadvertently do anything harmful.
If you think some thing need to be added to this list let me know.
access - determine whether a file can be accessed
Syntax
access -mode file
For more options and how to use check access man page

alias - define or display aliases
Syntax
alias [alias-name[=string] …]
For more options and how to use check alias man page

bg - run jobs in the background
Syntax
bg [job_id ...]
For more options and how to use check bg man page
cal - displays a calendar
Syntax
cal [-smjy13 ] [[ month ] year ]
For more options and how to use check cal man page

cd - change directories
Use cd to change directories. Type cd followed by the name of a directory to access that directory.Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below.
Syntax
cd [-L | -P] [directory]
For more options and how to use check cd man page

chown - change file owner and group
Syntax
chown [OPTION] OWNER[:[GROUP]] FILE
chown [OPTION] :GROUP FILE
chown [OPTION] --reference=RFILE FILE
For more options and how to use check chown man page

chmod - change file access permissions
Syntax
chmod [-r] permissions filenames
Options
r Change the permission on files that are in the subdirectories of the directory that you are currently in. permission Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha numeric format.filenames File or directory that you are associating the rights with Permissions
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.
r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.
Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
For more options and how to use check chmod man page



cp - Copy files and directories
Syntax
cp [OPTION]… SOURCE DEST
cp [OPTION]… SOURCE… DIRECTORY
cp [OPTION]… --target-directory=DIRECTORY SOURCE…
Options
cp myfile yourfile
Copy the files “myfile” to the file “yourfile” in the current working directory. This command will create the file “yourfile” if it doesn’t exist. It will normally overwrite it without warning if it exists.
cp -i myfile yourfile
With the “-i” option, if the file “yourfile” exists, you will be prompted before it is overwritten.
cp -i /data/myfile
Copy the file “/data/myfile” to the current working directory and name it “myfile”. Prompt before overwriting the file.
cp -dpr srcdir destdir
Copy all files from the directory “srcdir” to the directory “destdir” preserving links (-poption), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another dir
For more options and how to use check cp man page

clear - Clears the terminal screen.
Syntax
clear
For more options and how to use check clear man page

cmp - Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs.
Syntax
cmp [-clsv] [-i NUM] [--help] [--print-chars] [--ignore-initial=NUM] [--verbose] [--quiet] [--silent] [--version] -I FILE1 [FILE2 [RANGE1 [RANGE2]]]
For more options and how to use check cmp man page

cat - Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.
Syntax
cat [OPTION] [FILE]…
For more options and how to use check cat man page

diff - find differences between two files
Syntax
diff [options] from-file to-file
For more options and how to use check diff man page

dmesg - Prints the messages resulting from the most recent system boot.
Syntax
dmesg [ -c ] [ -n level ] [ -s bufsize ]
For more options and how to use check dmesg man page

du - estimate file space usage
Syntax
du [OPTION]… [FILE]…
For more options and how to use check du man page

df - report filesystem disk space usage
Syntax
df [OPTION]… [FILE]…
For more options and how to use check df man page

exit - cause the shell to exit
syntax
exit [n]
For more options and how to use check exit man page

eject - eject removable media
Syntax
eject -h
eject [-vnrsfqp] []
eject [-vn] -d
eject [-vn] -a on|off|1|0 []
eject [-vn] -c slot []
eject [-vn] -t []
eject [-vn] -x []
eject -V
For more options and how to use check eject man page

fuser - identify processes using files or sockets
Syntax
fuser [-a|-s|-c] [-4|-6] [-n space] [-k [-i] [-signal] ] [-muvf] name
fuser -l
fuser -V
For more options and how to use check fuser man page

fsck - check and repair a Linux file system
Syntax
fsck [ -sACVRTNP ] [ -t fstype ] filesys [ ... ] [--] [ fsck-options ]
For more options and how to use check fsck man page

fdisk - Partition table manipulator for Linux
Syntax
fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
fdisk -l [-u] device …
fdisk -s partition …
fdisk -v
For more options and how to use check fdisk man page

fg - run jobs in the foreground
Syntax
fg [job_id]
For more options and how to use check fg man page

file - determine file type
Syntax
file [ -bciknsvzL ] [ -f namefile ] [ -m magicfiles ] file …
file -C [ -m magicfile ]
For more options and how to use check file man page

find - search for files in a directory hierarchy
Syntax
find [path...] [expression]
For more options and how to use check find man page

finger - Prints descriptions of the specified users.
Syntax
finger [-lmsp ] [user ... ] [user@host ... ]
For more options and how to use check finger man page

free - Displays the amount of used and free system memory.
Syntax
free [-b | -k | -m] [-o] [-s delay ] [-t] [-V]
For more options and how to use check free man page

ftp - A File Transfer Protocol client
Syntax
ftp hostname or ipaddress
For more options and how to use check ftp man page

grep, egrep, fgrep - print lines matching a pattern
Syntax
grep [options] PATTERN [FILE...]
grep [options] [-e PATTERN | -f FILE] [FILE...]
For more options and how to use check grep, egrep, fgrep man page

head - output the first part of files
Syntax
head [OPTION]… [FILE]…
For more options and how to use check head man page

history - Manipulate the history list
Syntax
history option arg arg …
For more options and how to use check history man page

!!
use the ! option. To automatically re-display the last command you typed at the prompt, type: !! and press enter. Press again to invoke the command. You can also automatically re-display a command you typed earlier by using the ! and the first few letters of the command.
& operator
execute a command as a background process.
Ex:-
#top&
init - process control initialization
Syntax
/sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ]
For more options and how to use check init man page

ispell - ispell, buildhash, munchlist, findaffix, tryaffix, icombine, ijoin - Interactive spelling checking
Syntax
ispell [common-flags] [-M|-N] [-Lcontext] [-V] files
ispell [common-flags] -l
ispell [common-flags] [-f file] [-s] {-a|-A}
ispell [-d file] [-w chars] -c
ispell [-d file] [-w chars] -e[e]
ispell [-d file] -D
ispell -v[v]
For more options and how to use check ispell man page

id - Print real and effective user id (uid) and group id (gid), prints options about the given user, or if no user is specified the process running it
Syntax
id [options]… [username]
For more options and how to use check id man page

kill - terminate a process
Syntax
kill [ -s signal | -p ] [ -a ] [ -- ] pid … kill -l [ signal ]
For more options and how to use check kill man page

killall - kill processes by name
Syntax
killall [-Z,--context pattern] [-e,--exact] [-g,--process-group] [-i,--interactive] [-q,--quiet] [-r,--regexp] [-s,--signal signal] [-u,--user user] [-v,--verbose] [-w,--wait] [-I,--ignore-case] [-V,--version] [--] name … killall -l killall -V,--version
For more options and how to use check killall man page

logname - Print current login name
Syntax
logname [OPTION]
For more options and how to use check logname man page

less - Opposite of the more command
Syntax
less -?
less --help
less -V
less --version
less [-[+]aBcCdeEfFgGiIJmMnNqQrRsSuUVwWX]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[+[+]cmd] [--] [filename]…
For more options and how to use check less man page

logout - to quit using the system
Syntax
logout
lsof - list open files
Syntax
lsof [ -?abChlnNOPRstUvVX ] [ -A A ] [ -c c ] [ +c c ] [ +|-d d ] [ +|-D D ] [ +|-f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ +|-L [l] ] [ +|-m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x [fl] ] [ -z [z] ] [ -- ] [names]
For more options and how to use check lsof man page

ls - Short listing of directory contents
Syntax
ls [OPTION]… [FILE]…
Options
-a list hidden files
-d list the name of the current directory
-F show directories with a trailing ‘/’
executable files with a trailing ‘*’
-g show group ownership of file in long listing
-i print the inode number of each file
-l long listing giving details about files and directories
-R list all subdirectories encountered
-t sort by time modified instead of name
For more options and how to use check ls man page

ln - make links between files
Syntax
ln [OPTION]… TARGET [LINK_NAME]
ln [OPTION]… TARGET… DIRECTORY
ln [OPTION]… --target-directory=DIRECTORY TARGET…
Option
ln -s test symlink
Creates a symbolic link named symlink that points to the file test Typing “ls -i test symlink” will show the two files are different with different inodes. Typing “ls -l test symlink” will show that symlink points to the file test.
For more options and how to use check ln man page

locate - list files in databases that match a pattern
Syntax
locate [-d path | --database=path] [-e | --existing] [-i | --ignore-case ] [--version] [--help] pattern…
For more options and how to use check locate man page

mail - Launches a simple mail client that permits sending and receiving email messages.
Syntax
mail [OPTION...] [address...]
For more options and how to use check mail man page

man - an interface to the on-line reference manuals
Syntax
man [-c|-w|-tZHT device] [-adhu7V] [-m system[,...]] [-L locale] [-p string] [-M path] [-P pager] [-r prompt] [-S list] [-e extension] [[section] page …] …
man -l [-7] [-tZHT device] [-p string] [-P pager] [-r prompt] file …
man -k [apropos options] regexp …
man -f [whatis options] page …
For more options and how to use check man man page

mkdir - make directories
Syntax
mkdir [OPTION] DIRECTORY
Options
Create the Directory(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
-m, mode=MODE set permission mode (as in chmod)
-p, parents no error if existing, make parent directories as needed
-v, verbose print a message for each created directory
-help display this help and exit
-version output version options and exit
For more options and how to use check mkdir man page

mount - mount a file system
Syntax
mount [-lhV]
mount -a [-fFnrsvw] [-t vfstype] [-O optlist]
mount [-fnrsvw] [-o options [,...]] device | dir
mount [-fnrsvw] [-t vfstype] [-o options] device dir
For more options and how to use check mount man page

mv - change the name of a directory
Type mv followed by the current name of a directory and the new name of the directory
Syntax
mv [OPTION]… [-T] SOURCE DEST mv [OPTION]… SOURCE… DIRECTORY mv [OPTION]… -t DIRECTORY SOURCE…
Ex: mv testdir newnamedir
For more options and how to use check mv man page

more - Allows file contents or piped output to be sent to the screen one page at a time.
Syntax
more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ]
For more options and how to use check more man page

nohup - run a command immune to hangups, with output to a non-tty
Syntax
nohup COMMAND [ARG]…
nohup OPTION
For more options and how to use check nohup man page

nice - run a program with modified scheduling priority
Syntax
nice [OPTION] [COMMAND [ARG]…]
For more options and how to use check nice man page

ping - send ICMP ECHO_REQUEST packets to network hosts
Syntax
ping [-Rdfnqrv ] [-c count ] [-i wait ] [-l preload ] [-p pattern ] [-s packetsize ] host
For more options and how to use check ping man page

ps - report process status
Syntax
ps [options]
For more options and how to use check ps man page

pwd - print working directory
will show you the full path to the directory you are currently in. This is very handy to use, especially when performing some of the other commands on this page.
Syntax
pwd [OPTION]
For more options and how to use check pwd man page

passwd - change user password
Syntax
passwd [-f|-s] [name]
passwd [-g] [-r|R] group
passwd [-x max] [-n min] [-w warn] [-i inact] name
passwd {-l|-u|-d|-S|-e} name
For more options and how to use check passwd man page

reboot - Reboots the system (requires root privileges).
Syntax
/sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] [-h] /sbin/reboot [-n] [-w] [-d] [-f] [-i] /sbin/poweroff [-n] [-w] [-d] [-f] [-i] [-h]
For more options and how to use check reboot man page

rmdir - remove empty directories
Syntax
rmdir [OPTION]… DIRECTORY…
For more options and how to use check rmdir man page

rm - remove files or directories
Syntax
rm [OPTION]… FILE…
Option
rm -r - Removes directories and files within the directories recursively.
For more options and how to use check rm man page

renice - alter priority of running processes
Syntax
renice priority [[-p ] pid … ] [[-g ] pgrp … ] [[-u ] user … ]
For more options and how to use check renice man page
shutdown - bring the system down
Syntax
/sbin/shutdown [-t sec] [-arkhncfF] time [warning-message]
For more options and how to use check shutdown man page

sleep - delay for a specified amount of time
Syntax
sleep NUMBER[SUFFIX]…
sleep OPTION
For more options and how to use check sleep man page

sort - sort lines of text files
Syntax
sort [OPTION]… [FILE]…
For more options and how to use check sort man page
split - split a file into pieces
Syntax
split [OPTION] [INPUT [PREFIX]]
For more options and how to use check split man page

slocate - Security Enhanced version of the GNU Locate.
Syntax
slocate [-qi] [-d] [--database= ]
slocate [-i] [-r ] [--regexp=]
slocate [-qv] [-o ] [--output=] slocate [-e ] [-f ] <[-l ] [-c] <[-U ] [-u]>
slocate [-Vh] [--version] [--help]
For more options and how to use check slocate man page

sync - synchronize data on disk with memory

Syntax
sync [--help] [--version]

For more options and how to use check sync man page
su - run a shell with substitute user and group IDs
Syntax
su [OPTION]… [-] [USER [ARG]…]
For more options and how to use check su man page

telnet - user interface to the TELNET protocol
Syntax
telnet [-8] [-E] [-F] [-K] [-L] [-S tos] [-X authtype] [-a] [-c] [-d] [-e escapechar] [-f] [-k realm] [-l user] [-n tracefile] [-r] [-x] [host [port]]
For more options and how to use check telnet man page

top - display top CPU processes
Syntax
top [-] [d delay] [p pid] [q] [c] [C] [S] [s] [i] [n iter] [b]
For more options and how to use check top man page
talk - talk to another user
Syntax
talk person [ttyname]
For more options and how to use check talk man page

tree - list contents of directories in a tree-like format.
Syntax
tree [-adfgilnopqrstuxACDFNS] [-L level [-R]] [-H baseHREF] [-T title] [-o filename] [--nolinks] [-P pattern] [-I pattern] [--inodes] [--device] [--noreport] [--dirsfirst] [--version] [--help] [directory ...]
For more options and how to use check tree man page

tr - translate or delete characters
Syntax
tr [OPTION]… SET1 [SET2]
For more options and how to use check tr man page

time - time a simple command or give resource usage
Syntax
time [options] command [arguments...]
For more options and how to use check time man page

tty - print the file name of the terminal connected to standard input
Syntax
tty [OPTION]…
For more options and how to use check tty man page

touch - change file timestamps
Syntax
touch [OPTION]… FILE…
For more options and how to use check touch man page

tail - output the last part of files
Syntax
tail [OPTION]… [FILE]…
For more options and how to use check tail man page

traceroute - print route packets take to network host
Syntax
traceroute [-adnruvAMOQ] [-w wait_time] [-S start_ttl] [-m max_ttl] [-p port] [-q nqueries] [-g gateway] [-t tos] [-s src_addr] [-g router] host [packet size]
For more options and how to use check traceroute man page

uptime - Tell how long the system has been running.
Syntax
uptime
uptime [-V]
For more options and how to use check uptime man page

umount - unmount file systems
Syntax
umount [-hV]
umount -a [-dflnrv] [-t vfstype] [-O options]
umount [-dflnrv] dir | device [...]
For more options and how to use check umount man page

umask - get or set the file mode creation mask
Syntax
umask [-S][mask]
For more options and how to use check umask man page

ulimit - Control the resources available to a process started by the shell, on systems that allow such control.
Syntax
ulimit [-acdfHlmnpsStuv] [limit]
For more options and how to use check ulimit man page

uname - print system options
Syntax
uname [OPTION]…
For more options and how to use check uname man page

uniq - report or omit repeated lines
Syntax
uniq [OPTION]… [INPUT [OUTPUT]]
For more options and how to use check uniq man page

vdir - list directory contents
Syntax
vdir [OPTION]… [FILE]…
For more options and how to use check vdir man page

w - Show who is logged on and what they are doing.
Syntax
w - [husfV] [user]
For more options and how to use check w man page

wall - send a message to everybody’s terminal.
Syntax
wall [-n] [ message ]
For more options and how to use check wall man page

who - show who is logged on
Syntax
who [OPTION]… [ FILE | ARG1 ARG2 ]
For more options and how to use check who man page


Syntax
whoami [OPTION]…
For more options and how to use check whoami man page

watch - execute a program periodically, showing output fullscreen
Syntax
watch [-dhv] [-n ] [--differences[=cumulative]] [--help] [--interval=] [--version]
For more options and how to use check watch man page

whereis - locate the binary, source, and manual page files for a command
Syntax
whereis [ -bmsu ] [ -BMS directory... -f ] filename …
For more options and how to use check whereis man page

wc - print the number of newlines, words, and bytes in files
Syntax
wc [OPTION]… [FILE]…
For more options and how to use check wc man page

xload - system load average display for X
Syntax
xload [-toolkitoption ...] [-scale integer] [-update seconds] [-hl color] [-highlight color] [-remote host] [-jumpscroll pixels] [-label string] [-nolabel] [-lights]
For more options and how to use check xload man page

No comments:

Post a Comment