25
Linux Commands LINUX COMMANDS Ramiz Ahmed

0..Linux Commands

Embed Size (px)

Citation preview

Page 1: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 1/25

Linux Commands

LINUX COMMANDSRamiz Ahmed

Page 2: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 2/25

UNIX Commands

Linux Commands

A command is a program which interacts with thekernel to pro ide the en ironment and per!orm the!"nctions called !or #$ the "ser%

A command can #e& a #"ilt'in shell command( ane)ec"ta#le shell !ile* known as a shell script( or aso"rce compiled* o#+ect code !ile%

,he shell is a command line interpreter% ,he "serinteracts with the kernel thro"gh the shell% -o" can write ASCII .te)t/ scripts to #e acted "pon #$ ashell%

Page 3: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 3/25

Command Str"ct"re

Linux Commands

Command 0Options1 0Arg"ments1

M"ltiple commands separated #$ ( can #e e)ec"tedone a!ter the other

Page 4: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 4/25

2elp 3acilities !or Commands

Linux Commands

,o "nderstand the working o! the command andpossi#le options "se .man command/

Using the 4NU In!o S$stem .in!o* in!o command/

Listing a Description o! a 5rogram .whatis command/

Man$ tools ha e a long6st$le option* 766help8* thato"tp"ts "sage in!ormation a#o"t the tool* incl"dingthe options and arg"ments the tool takes% 9)&whoami --help

Page 5: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 5/25

5ipes

Linux Commands

An important earl$ de elopment in Uni) was thein ention o! :pipes*: a wa$ to pass the o"tp"t o! onetool to the inp"t o! another%

eg% ; who < wc 6l

=$ com#ining these two tools* gi ing the wccommand the o"tp"t o! who* $o" can #"ild a new

command to list the n"m#er o! "sers c"rrentl$ on thes$stem

Page 6: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 6/25

Linux Commands

3ile and Director$ management

cd Change the current directory. With no arguments "cd"changes to the users home directory. (cd <directory path>)

chmod Change the file permissions.

Ex: chmod 7 ! myfile : change the file permissions to r x foro ner# rx for group and x for others

Ex: chmod go$%r myfile : &dd read permission for the groupand others (character meanings u'user# g'group# o'other# %add permission#'remo e#r'read# ' rite#x'exe)

Ex: chmod %s myfile ' etuid *it on the file hich allo s theprogram to run ith user or group pri ileges of the file.

Page 7: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 7/25

Linux Commands

+here are three such special permissions ithin ,inux. +hey are:setuid - used only for applications# this permission indicates that the application is torun as the o ner of the file and not as the user executing the application. t is indicated*y the character s in place of the x in the o ner category. f the o ner of the file doesnot ha e execute permissions# the is capitali/ed to reflect this fact.setgid - used primarily for applications# this permission indicates that the applicationis to run as the group o ning the file and not as the group of the user executing theapplication. +he setgid permission is indicated *y the character s in place of the x inthe group category. f the group o ner of the file or directory does not ha e executepermissions# the is capitali/ed to reflect this fact.sticky bit - used primarily on directories# this *it dictates that a file created in thedirectory can *e remo ed only *y the user that created the file. t is indicated *y thecharacter t in place of the x in the e eryone category. f the e eryone category does notha e execute permissions# the + is capitali/ed to reflect this fact.

Page 8: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 8/25

Linux Commands

chown Change o ner.

Ex: cho n <o ner!> <filename> : Change o nership ofa file to o ner!.

chgrp Change group.Ex: chgrp <group!> <filename> : Change group of a file

to group!.

cp Copy a file from one location to another.

Ex: cp file! file0 : Copy file! to file0

Ex: cp 12 dir! dir0 : Copy dir! to dir0

md>s"m 3rints the 45 Chec6sum

Page 9: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 9/25

Linux Commands

ls ,ist contents of a directory.

Ex: ls# ls 1l # ls 1al# ls 1ld# ls 12

('r xr xr'x ! uan uan 8 ep 09 !0:0 foo )

more ill list page ise

mkdir 4a6e a directory.

Ex: m6dir <directory name> : 4a6es a directory

Ex mkdir –p /www/chache/var/log ill create all the directoriesstarting from .

m 4o e or rename a file or directory.

Ex: m <source> <destination>

Page 10: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 10/25

Linux Commands

!ind ;ind files (find <start directory> 'name <file name> 'print)

Ex: find /home –name readme -print ( earch for readme starting at home and output full path.)

=home" $ earch starting at the home directory and proceedthrough all its su*directories"'name readme" $ earch for a file named readme"'print" $ utput the full path to that file

locate ;ile locating program that uses the slocate data*ase.Ex: locate 1u to create the data*ase#

locate <file=directory> to find file=directory

Page 11: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 11/25

Linux Commands

pwd 3rint or list the present or6ing directory ith fullpath.rm 5elete files (2emo e files). (rm 1rf <directory=file>)

rmdir 2emo e a directory. +he directory must *e empty.(rmdir <directory>)to"ch Change file timestamps to the current time. 4a6ethe file if it doesn?t exist. (touch <filename>)

whereis ,ocate the *inary and man page files for acommand. ( hereis <program=command>)

which ho full path of commands here gi encommands reside. ( hich <command>)

Page 12: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 12/25

Linux Commands

3ile iewing and editing

emacs ;ull screen editor.

pico imple text editor.

i Editor ith a command mode and text mode. tarts in commandmode.

gedit @A +ext Editor

tail ,oo6 at the last !8 lines of a file.

Ex: tail 1f <filename> #Ex: tail '!88 <filename>

head ,oo6 at the first !8 lines of a file. (head <filename>)

Page 13: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 13/25

Linux Commands

3ile compression* #acking "p and restoringcompress Compress data."ncompress Expand data.

cpio Can store files on tapes. to=from archi es.gzip ' /ip a file to a g/ file.g"nzip ' un/ip a g/ file.tar &rchi es files and directories. Can store files and directorieson tapes.

Ex: tar '/c f <destination> <files=directories> ' &rchi e copygroups of files. tar 1/x f <compressed file> to uncompresszip 1 Compresses a file to a ./ip file."nzip 1 Ancompresses a file ith ./ip extension.

Page 14: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 14/25

Linux Commands

cat Bie a file

Ex: cat filename

cmp Compare t o files.c"t 2emo e sections from each line of files.

di!! ho the differences *et een files.

Ex: diff file! file0 : ;ind differences *et een file! file0.

echo 5isplay a line of text.

Page 15: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 15/25

Linux Commands

grep ,ist all files ith the specified expression.(grep pattern <filename/directorypath >)

Ex: ls 1l grep sid*i : ,ist all lines ith a sid*i in them.

Ex: grep " 2 " : earch for 2 ith a space on each side

sleep 5elay for a specified amount of time.

sort ort a file alpha*etically.

"ni? 2emo e duplicate lines from a sorted file. wc Count lines# ords# characters in a file. ( c 1c= =l<filename>).

Page 16: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 16/25

Linux Commands

● who – User currently logged into server.● who m i – display the queering machine logged into server.● clear

– clear user screen and returns a single prompt.● exit – end current session.● useradd – create new user.● userdel – delete user.● groupadd – add a group.● groupdel – delete a group.

Page 17: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 17/25

Linux Commands

● passwd – modify user password.● usermod – modify user profile.● ps – for check process.

– To see every process on the system using standardsyntax:

ps -e , ps -ef , ps -ely , ps-el– Print only the name of PID 42:

ps -p 42 -o comm

Page 18: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 18/25

Linux Commands

● man<command name> - give manual of command.● arch – displays machine architecture type.●

asciitopgm – convert ASCII graphics into portablegraymap.● Synopsis asciitopgm[-d divisor] height width[asciifile]→

● bitmap – bitmap editor and converter utilities for the x-

windows system.bitmap[-option...][filename][basename]

tool for creating or editing rectangular images made up of 1's ando's.

Page 19: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 19/25

Linux Commands

● cal – displays a calender– cal [-jy][month [year]]– cal july 1988– -j display julian date– -y display calender for current year.

● chkdupexe – find duplicate executable files.● df – summarize free disk space

● -a all●

-k kilobytes● du – summarize disk usage

● -a all● -b bytes● -c total

Page 20: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 20/25

Linux Commands

● merge – three way file merge– merge [options] file1 file2 file3– Merge incorporates all changes that load from file2 to file3 into

file1. This result ordinarily goes into file1.● newgrp – login into a new group

● newgrp[group]● oclock – round x clock ● pstree – display a tree of process

● -h highlight the current process and its ancestors.● reset – reset the terminal.

Page 21: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 21/25

Linux Commands

● rev – reverse lines of a file– rev[filename]

● top – display top CPU process.● userlist – user listing of who's on your system. This

program simply gives you a listing of who is connected toyour system.

● w – present who users are and what they are doing. The wutility prints a summary of the current activity on thesystem, including what each user is doing.

● xclock – analog/digital clock ● xclock [-analog] [-digital] [-chime]

Page 22: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 22/25

Linux Commands

● xkill – kill a client by its x resource. By thiscommand be get a cross mask and when we clickon any process then that process is killed(exit).

● xlsatoms – list interned atoms defined on server– xlsatoms [-options]

● -display specifies the x server to which to connect● -format● -range

By default all atoms starting from 1(the lowestvalue defined by the protocol) are listed untilunknown atom in found.

Page 23: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 23/25

Linux Commands

● xmag – magnify part of the screen.● xterm – terminal emulator for x

● The x term program is a terminal emulator for the x windowsystem. It provides DEC VT 102 and tektronix 4014 compatibleterminal for programs that cant use the window system directly.The VT 102 and tektronix 4014 terminals all have their ownwindows so that you can edit text in one and look at graphics inthe other at same time.

● su – switch user, change root to simple user.● Indent – Indentation, changes the appearance of a C

program by inserting or deleting whitespace.● indent <filename>

Page 24: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 24/25

Linux Commands

● bc – a text based calculator.● xcalc – graphical based calculator.● more and less – commands are used to view large

files one page at a time.– more <filename>– less <filename>

Page 25: 0..Linux Commands

8/11/2019 0..Linux Commands

http://slidepdf.com/reader/full/0linux-commands 25/25

Linux Commands

THANK YOU