mpdf (1)
mpdf (1)
Directory Contains
bin/ Required Boot-time binaries
Boot configuration files for the OS
boot/
loader and kernel image
dev/ Device files
System configuration files and
etc/
scripts
home/ User/Sub branch directories
Main OS shared libraries and kernel
lib/
modules
Storage directory for “recovered”
Lost+found/
files
mnt/ Temporary point to connect devices to
Pseudo directory structure containing
information about the kernel,
proc/
currently running processes and
resource allocation
Linux (non-standard) home directory
root/ for the root user. Alternate location
being the / directory itself
System administration binaries and
sbin/
tools
tmp/ Location of temporary files
Difficult to define – it contains
almost everything else including
usr/ local binaries, libraries,
applications and packages (including
X Windows)
Variable data, usually machine
var/ specific. Includes spool directories
for mail and news
echo $PATH
/bin:/usr/bin:/usr/local/bin:$HOME/bin
which ls
date –help
info date
man date
whatis date
Extended Documents:=/usr/share/doc
TO CHANGE CONSOLE
Ctrl+alt+(F1-F7)
CHANGING DIRECTORY
cd /home/deb/work
ls /
ls –l [long listing]
Option Action
COPYING FILES
cp source destination
pathname.]
rm chap[1-2][wildcard is used]
rm -i chap1[Removing interactively]
file deb.sh
HANDLING PRINTERS
lp deb.lis[Printing file]
COUNTING LINES
wc deb.txt
wc -c[No. of characters]
wc -l[No. of lines]
COMPRESSING FILES
compress deb.txt
uncompress deb.txt
gzip deb
gunzip deb.z
SORTING
sort /etc/passwd
sort in order based on the whole line
sort -r /etc/passwd
reverse the order of the sort
uniq names
remove duplicate lines from names and display them on the
screen
uniq -d names
display all duplicate lines
ln -s source linkname
ln -s reports/reportA publications/my_report
FIND Command
To find files in /etc directory that begin with host, and any
other characters after
that:
Find all files that begin with two lower case characters,
followed by two numbers,
To find files that are read, write and executable for everyone
(watch out for these) use
permissions and 007 is based on the notation you use for the
chmod (absolute) mode.
Ignoring directories
in /apps/bin:
To find files of a user that has been deleted, use the -nouser
option. This
supply a user name with this option; find will go off and do
all the work. To find
Like the user and nouser option, find has the same options for
groups. To find all
To find all files that have been modified in the last five
days:
days:
To do this … Command
vi -r help.xdh
Viewing a file
view filename
Press the ESC key to enter command mode before using these
com-mands.
To move to Do this …
next character l
previous character h
next word w
next n words wn
previous word b
previous n words bn
Press the ESC key to enter command mode before using these
com-mands.
To move to Do this …
(same column)
previous line k
(same column)
Deleting characters
Press the ESC key to enter command mode before using these
com-mands.
To delete Do this
current character x
previous character dh
Press the ESC key to enter command mode before using these
com-mands.
To delete Do this
current word dw
previous word db
entire line dd
to end of line d$
To get back a word or line that you have just deleted enter
the command:
Press the ESC key to enter command mode before using these
com-mands.
To search Do this …
reverse direction
:s/that/which
another:
:s/destroy/delete/g
another:
:g/insert/s//add/g
:%s/^v^M/ /g
30 21 * * * /apps/bin/cleanup.sh
45 4 1,10,22 * * /apps/bin/backup.sh
of each month.
0 23 * * 6 /apps/bin/qtrend.sh
where:
$ ps x|grep 28305
$ kill 28305
$ kill -9 28305
ls -l file1
unixjohn – owner
user:
r w x r w x r w x
5.Changing permission
.pub.
r w x
4 2 1
These values are added together for any one user category:
1 = execute only
2 = write only
4 = read only
ulimit 234567
9.Changing password
passwd
ECHO
$ read name
You have to put a ‘-n’ after the echo to suppress the new
line:
You have to put a ‘-e’ after echo for the escape code to work:
‘tty‘”
READ
$ read name
Hello I am superman
$ echo $name
Hello I am superman
John Doe
$ echo $name $surname
John Doe
$ pg var_test
#!/bin/sh
# var_test
read 51
read name
read middle
read surname
$ pg var_test
#!/bin/sh
# var_test
read name
read surname
PIPES
matthew pts/0
louise pts/1
hda5
hda8
hda6
hdb5
hdb1
hda7
hda1
TEE
The tee command acts the way it is pronounced. It takes the
input and sends
your output and save it to a file at the same time, then this
is the command for
you.
tee -a files
cat who.out
$ ls -l | grep ^d >>files.out
> bye…
> MAYDAY
$ pg myfile
example.
In the above example the script cleanup directs all output (>)
to a file called
cleanup.out, and all errors (2), are directed to (>) the same
place as the output
In the above example all output from the grep command is put
into the output file
grep.out. When you use here documents, you will probably need
to capture all the
> MAYDAY
Using &&
OK”
Using ||
command1 || command2
executed.
from an accounts file and stick the output into a temp file.
If the extraction does not
You don’t always have to use system commands; here I run the
script comet on a file
Using GREP
would do this:
$ grep “sort” * .doc
Or I could search through all the files that have the word
“sort it”.
Line matches
$ 4
Line numbers
Do not match
Being case-sensitive
Pattern ranges
Date searching
$ grep ‘5..199[6,8]’ data.f
Combining ranges
get city codes where the first character could be any number,
the second character
following output:
that have been returned are the correct ones according to our
rules. We need to
that.
Occurrences in a pattern
use this:
number or maybe a letter. This will match between two and six
occurrences of the
83 – no match
888883 – match
8884 – no match
88883 – match
Blank lines
$ grep ‘^$’ myfile
you want to search for all lines that contain a period (.),
you would do this:
and forget about the rest that have only two digits in the
second part, i.e. nnn.nn..
this:
$ pg testfile
looks
likes
looker
long
looks
likes
looks
likes
looks
That will search all files for lines that have the word
‘device’ at the end of each line.
Class names 91
All this is saying is that you have typed a filename that does
not exist. If we
grep is not only reserved for files; you can also use grep on
strings. All you need to
egrep
$ pg grepstrings
484
47
If we want to search for store codes 32L or 2CC we can use the
bar sign (|),
matty or pauline were logged into the system we could use the
who command and
louise pty8
matty tty02
pauline pty2
You can also exclude certain strings using the caret sign (^).
If I wanted to see who
was on the system, but I did not want to know if users matty
and pauline were on I
could do this:
USING AWK
$ pg grade.txt
Name Belt
—————————————
M.Tansley Green
J.Lulu green
P.Bunny Yellow
J.Troll Brown-3
L.Tansley Brown-3
grade.txt
Matching
Exact match
Not matched
$ awk ‘$0 !~ /Brown/’ grade.txt
We could have targeted just the belt grade field ‘field-4’ and
done the test this way:
Less than
$ awk ‘{if ($6 < $7) print $0 “$1 Try better at the next
comp”}’
grade.txt
Any characters
Match either
AND
OR
grade.txt
$ awk ‘{if (NR >0 && $4~/Brown/)print $0}’ grade.txt
“belts}’ grade.txt
debasis 1
debraj 1
debajyoti 1
debasis 1
deb 1
debraj 1
debajyoti 1
deb 1
Mdebasis 1
Mdebraj 1
Mdebajyoti 1
Mdebasis 1
debasisM 1
debrajM 1
debajyotiM 1
debasisM 1
debasisM 1
debrajM 1
debajyotiM 1
debasisM 1
debasis 2
debraj 1
debajyoti 1
debasis 2
debasis 2
debraj 1
debajyoti 1
debasis 1
[root@debasis cls]# sed ‘1,2 s/1/2/’ deb
debasis 2
debraj 2
debajyoti 1
debasis 1
deb 1
deba 1
debajyoti 1
deb 1
debasis 1
debraj 2
debajyoti 3
debasis 1
debasis 1
debajyoti 1
debasis 1
debasis 2
debajyoti 1
debasis 2
> stop!!!\
debasis 1
debraj 1
debajyoti 1
debasis 1
stop!!!
I am lost
stop!!!\
I am lost’ deb
debasis 1
debraj 1
debajyoti 1
stop!!!
I am lost
debasis 1
stop!!!\
I am lost’ deb
debasis 1
debraj 1
stop!!!
I am lost
debajyoti 1
debasis 1
[cls@debasis cls]$ sed ‘/debasis/ c\
no use
debraj 1
debajyoti 1
no use
Local variables
Displaying a variable
$ GREAT_PICTURE=”die hard”
$ echo ${GREAT_PICTURE}
die hard
$ DOLLAR=99
$ echo ${DOLLAR}
99
$ LAST_FILE=ZLPSO.txt
$ echo ${LAST_FILE}
ZLPSO.txt
Clearing a variable
unset variable_name
$ PC=enterprise
$ echo ${PC}
enterprise
$ unset PC
$ echo ${PC}
$ set
PWD=/root
SHELL=/bin/sh
SHLVL=1
TERM=vt100
UID=7
USER=dave
dollar=99
great_picture=die hard
last_file=ZLPSO.txt
$ SOURCE=”/etc/passwd”
$ DEST=”/tmp/passwd.bak”
$ cp ${SOURCE} ${DEST}
$ TAPE_DEV=”/dev/rmt/0n”
$ echo ${TAPE_DEV}
/dev/rmt/0n
$ readonly TAPE_DEV
$ TAPE_DEV=”/dev/rmt/1n”
SHELL SCRIPTING
-x This is executable
an error.
$ ls -l scores.txt
$ [ -w scores.txt ]
$ echo $?
$ test -w scores.txt
$ echo $?
0
cutting columns(-c)
pasting columns
$ [ -w results.txt -a -w scores.txt ]
$ echo $?
Testing strings
$ [ -z $EDITOR ]
$ echo $?
$ [ $EDITOR = “vi” ]
$ echo $?
Testing numbers
$ echo $?
Using expr
1500
$ expr 30 / 3
10
$ expr 30 / 3 / 2
Incrementing counters
$ LOOP=0
$ LOOP=‘expr $LOOP + 1‘
Pattern matching
$ VALUE=accounts.doc
12
$ pg iftest
#!/bin/sh
# iftest
then
fi
Testing values of variables
$ pg iftest2
#!/bin/sh
# if test2
read NAME
if [ “$NAME” = “” ] ; then
fi