Beruflich Dokumente
Kultur Dokumente
Tilde (~)
cat ~/.bash_profile
Refer to root's home directory
ls ~ <uname>
Refer to another user's home directory
$ or ``
echo "This system's name is $(hostname)"
This system's name is server1.example.com
echo "This system's name is `hostname`"
This system's name is server1.example.com
COMMAND EDITING TRICKS
Ctrl-a moves to beginning of line
Ctrl-e moves to end of line
Ctrl-u deletes to beginning of line
Ctrl-k deletes to end of line
Ctrl-arrow moves left or right by word
GNOME-TERMINAL OPTIONS
Ctrl-Shift-t creates a new tab
Ctrl-PgUp/PgDn switches to next/prev tab
Ctrl-Shift-c copies selected text
Ctrl-Shift-v pastes text to the prompt
SHELL SCRIPTING
vim shell.sh
#!/bin/bash
# This script displays some information about your environment
echo "Greetings. The date and time are $(date)"
echo "Your working directory is: $(pwd)"
chmod u+x shell.sh
SHEBANG USE
#!/bin/bash
Ex:
Pipes (|) is used to redirect output from one command to become the
input to another command.
Ex:
CHANGE CASE
tr 'a-z' 'A-Z' < .bash_prof ile
(or)
cat .bash_profile | tr 'a-z' 'A-Z'
head /etc/passwd
head -n 5 /etc/passwd
TAIL
Displays last 10 lines of text in a file.
Ex:
tail /etc/passwd
tail -n 5 /etc/passwd
tail -f /var/log/secure (follow new additions)
GREP
Prints lines of files or STDIN where a pattern is matched
Ex:
WC
Counts words, lines, bytes and characters.
Ex:
wc /etc/passwd
wc -l /etc/passwd (lines)
wc -w /etc/passwd (word)
wc -m /etc/passwd (character)
SORT
Sorts text to stdout
Ex:
sort /etc/passwd
sort -r /etc/passwd (reverse)
sort -n /<file name> (numeric)
sort -u <filename> (removes duplicate lines)
UNIQ
Removes successive,duplicates lines in file
Ex:
DIFF
Compares two files for differences
diff <filename1> <f ilename2>
diff output stored in a file is called a "patchfile"
Use -u for "unif ied" diff, best in patchfiles
patch duplicates changes in other files (use with care!)
Use -b to automatically back up changed files
TO CREATE PATCH FILE
diff -u <file1> <file2> > name.patch
TO APPLY THE PATCH TO A NEW FILE
patch -b <newfile> <patchfile>
ASPELL-CHECK
Ex:
SED
Ex:
Stream editor
Ex:
locate <filename>
locate passwd
Note: updatedb command is used before running the locate comma nd.
EDITORS
vim, gvim, nano, gedit.
Note: gvim Editor is provides by vim-X11 package
VI AND VIM EDITOR
- vi (visual editor) , standard linux and unix editor
- vim (vi improved) , standard RedHat editor
- vim <f ile name>
THREE MODES
COMMAND MODE:
Esc + p
Esc + 10yy
search
/<text >
Move by word: w, b
Move by sentence: ), (
Move by paragraph: }, {
Jump to line x: xG
Jump to end: G
INSERT MODE:
EX MODE:
:w
:wq
:q!
VISUAL MODE:
Allows selection of blocks of text
v starts character-oriented highlighting
V starts line-oriented highlighting
Visual keys can be used in conjunction with movement keys:
w, ), }, arrows, etc
Note: Highlighted text can be deleted, yanked, changed, filtered, search/replaced, etc.
Multiple documents can be viewed in a single vim screen.
o
SYSTEM CONFIGURATION:
ifconfig eth0
ifup eth0
ifdown eth0
netconfig
DEVICE
ONBOOT
BOOTPROTO
IPADDR
0-127
CLASS B
128-191 (MEDIUM)
CLASS C
192-223 (SMALL)
CLASS D
CLASS E
240-255 (RESEARCH)
NETWORK ID
(LARGE)
10
PRIVATE IPADDR
10.0.0.0
- 10.255.255.255
172.16.0.0
- 172.31.255.255
192.168.0.0 - 192.168.255.255
NETMASK
Ex:
255.0.0.0
(or)
CLASS B
255.255.0.0
(or)
16
CLASS C
255.255.255.0 (or)
24
GATEWAY
HOSTNAME
GATEWAY
PDF VIEWER
evince <f ilename.pdf >
11