1.To move a file from source directory to destination directoery
----------------------------------------------------------------------------------------------
mv sourcedirpath/filename dest_dir path
Note:
if the source dir is in dest_dir path for dest_dir ------ ./
2.To copy the text in VI editor and paste
ESC+yy+num of lines
for pasting - press p
3. For extracting files from .tgz file
tar -zxvf zipfile.tgz
or
tar -zxvf zipfile.tgz -C dest_dirpath
tar -jxvf zipfile.bz2 -C dest_dirpath
4.For zipping a folder
tar -zcvf zipfile.tgz foldername
5. Generic form of chmod command
chmod category+permissin
owner - group - others
category - ugo(user group other and a-all)
note:
file permission format
d rwx rwx rwx
permission - rwx(read write exec)
To change the group of file
chgrp newgrp filename/directoryname
To change the username or ownership of file or directory
chown -v newusername:newgroup file/directory
Note: to change owner ship and group of the files which are in a folder recursively we shoould use -R attribute
ex:-chown -R newusername Dir
changes the directory as well as all the files user name to new username.
6. To copy the folder (zip or file) command
scp zipfolder root@IPadress:
=> For remote login in through particular ip
ssh root@IPAddress
note:
befor copy u need to ping the host id whether it is connected or not
7. To view pdf in command line is
if the system is Gnome based
>evince file.pdf
or
>gpdf file.pdf
8. Soft link
ln -s source source_link
9. Hard link a file
ln source source_link
10. updatedb & (update data base for locate or find files here & - is for back ground process running)
11. locate -b '\filename' (to find files that matches the basename with filename )
locate filename (if matches the whole pathname)
Note: reads one or more data bases prepared by updatedb and display on std output
12. cp srcefile destfile
for copying srcfile to destfile
cp -i srcfile destfile (copying with interaction)
response :- cp: overwrite `file2'? n
13.mv file file1 - renames file with file1
mv file dir/file2 - moves file to dir and rename it with file2
14. rm -i file - deletes the file with interaction
15.Steps to unpack,compile and installing the software
# tar xvzf package.tar.gz (or tar xvjf package.tar.bz2) //un pack the compressed tar file
# cd package //cd into it
# ./configure //generate a make file
# make //build the pgm and generate executable binaries
# make install //install the software
16. To view pdf in command line is
if the system is Gnome based
>evince file.pdf
or
>gpdf file.pdf
17 To know version of Fedora
$cat /etc/issue
18. grep - command usage (to search a pattern in files default it is case sensitive)
a)grep 'string' file1 file2 . . . .filen
b)grep 'fred' /etc/passwd (search for all lines in file passwd which has fred string and display them)
c)grep 'fred' * (search for fred in all files in a current directory)
d)grep 'joe' *.txt (all files inc urrent directory with .txt extension)t
e)grep -i score gettysburg-address.txt (-i - for case insensitive)
f)ls -al | grep '^d' (list the lines which start with 'd' i.e directory)
g)egrep 'score|nation|liberty|equal' file.txt (for searching multiple patterns in a file.txt)
h)grep -l pattern * (list the values which match the pattern )
Commands related to netperf:
client side:
TCP test:
netperf -H 192.168.0.57 (connecting to remote host name or remote ip)
netperf -H 192.168.0.57 -- -m sizeofdata
UDP test:
netperf -H 192.168.0.57 -- -m sizeofdata -t UDP_STREAM
Server side:
netsrever
tcpdump -ni plx-nl //to capture the data on interface plx-nl
About eethtool
ethtool -S plx-nl
Iperf tool:
TCP test:
iperf -c 10.1.1.2 -p 8880 -l 4k
for sending 4kbytes length of data.
iperf -c 10.1.1.2 -p 8880 -l 4M -w 512k -P 8
for create 8 threads and set window size 512k.
server side :
iperf -s -p 8880
UDP test:
client side:
iperf -c 10.1.1.2 -u -p 8880 -l 4k
for sending 4kbytes length of data.
iperf -c 10.1.1.2 -p 8880 -l 4M -w 512k -P 8
for create 8 threads and set window size 512k.
server side :
iperf -s -u -p 8880
Pinging :
ping -s 1472(size) -M do 10.1.1. (Ping with do not fragment set)
for terminal split to see multiple files:
command - open one file then :sp secondfilename tobe opened
ctrl+w and up ,down and side arrows to navigate the control between files.
Key Board short cuts:
ctrl+Alt+Fn -- open the nth virtual terminal
ctrl+a --- move cursor to begining of current ine
ctrl+e --- Move the cursor to the end of the current line.
Alt + b --- Move the cursor to the beginning of the current or previous word.
Alt + f ---- Move the cursor to the end of the next word.
Ctrl + u ---- Erase the current line.
Ctrl + k ---- Delete the line from the position of the cursor to the end of the line.
Ctrl + w ---- Delete the word before the cursor.
Ctrl + c ---- Kill the current process.
Ctrl + z ---- Send the current process to background.
Ctrl + d ---- Log out from the current terminal.
Ctrl+l ---- Clear the terminal.
Ctrl+Alt+del ---- Re - boot the system
Note:
./ represents the current directory
.. represents the parent directory
Cscope:
1.To create ctags ----------- ctags -R
2.for cscope ----------- cscope -R
3.For function definition from calling -------------- ctrl+}
4.Back to function calling -------------- ctrl+t
5.To display filename,line number -------------- ctrl+g
VI editor commands:
To delete 10 lines below cursor is ------ d+10+d
to copy 10 lines below cursor is ------ y+10+p
:%s/old_str/new_str/g - to replace old string with new (g-global c- confirmation)