LINUX COMMON USE COMMANDS
sudo dpkg -i package_name.deb
To install a package which is in debian package
who
show the current users have been logged on --> who
alias
make an alias name for any command like 'ls -l' → alias list='ls -l'
unalias
remove alias definition --> unalias list
whereis
gives address of binary, source and manual pages → whereis ls
whatis
display manual page description or tells short description
about any command --> whatis man
man
used 4 manual help/brief description of any command with options --> man ls
whoami
tells effective userid means your user id --> whoami
ls
list directory contents
dir
list directory contents
cd
changing directory --> cd foldername
mkdir
make directory --> mkdir foldername
apt-get install
search and install package direct form internet (for install netbeans on your pc) --> apt-get install netbeans-7.0.1-ml-javaee-linux.sh
aptitude
high level interface for package manager in terminal for checking all installed packages and available packages for new installation
aspell
spelling checker in file (here aspell and check are both keywords followed by filename)--> aspell check abc.txt
Ctrl + Z
/ Ctrl + D
for killing current process
read
read from keyboard for generally shell scripting files --> read x
cal
displays calender and date of Easter
cat
creating,viewing,concatenate of text file
chmod
changes the file permission for (read, write and execution)
--> chmod 755 filename
clear
clear screen
cmp
compare two files
cp
copy files from one location to another --> cd file1 /opt/file1
date
writes date and time
df
report free disk space
du
report about disk usage
diff
compare files line by line --> diff fileone filetwo
history
for viewing all different command used in terminal recently
echo
for showing any message it can be anything string, integer or float value --> echo "prem bharti"
ifconfig
getting all information about your network connection like
ipaddress,subnetmast, gateway etc
bg
runjobs in background
fg
runjobs in foreground
id
returns user identity
head
gives output given first part of file (for showing first 2
lines of file abd) --> head -2 abd
ln
create a linkfile for original file --> ln abc.sh $HOME/Desktop/abd.sh
more
display file on page by page basis
mv
moving a file to another location --> mv filename /otherdirectory/filename
ps
-Al
gives snapshot of current running processes
netstat
Print network connections, routing tables, interface statistics, masquerade
connections, and multicast etc.
pwd
gives present working directory
rmdir
removes given directory --> rmdir nameofdirectory
sleep
suspends given process for given time (we want to sleep mplayer music software for 10 sec --> sleep 10 ; mplayer foo.mp3
tail
output last part of files
wc
gives output in form of no. of lines, words, characters in a file --> wc filename
uniq
used for file and output doesn't contain repeated line --> uniq filename
touch
change a file's access and modification timestamps. Also
create a new empty file. --> touch filename
sudo shutdown now
Shutdown the computer at a time..
echo $HOME
path of home
x=10; export x
save variable value to shell terminal
watch -n 5 “cat xyz”
display periodically xyz file after 5 seconds
echo $USERNAME
show username
passwd
change userpassword
eject -T
open tray of cdrom if it's closed and vice versa
fdformat
low level floppy disk format
arch
print machine architecture
iptraf
Interactive Colorful IP LAN Monitor (may need to install)
w username
i.e. w love → Find out who is logged in what is he doing..
tty
file name for the terminal
traceroute www.google.com
trace hostname from your system node by node
(u may hv to install – use sudo apt-get install traceroute)
ls>xyz
output of ls will be write into xyz named file
ls>>xyz
output of ls will be append into xyz named file
# GREP UTILITY --> prints line matching a pattern
grep “searchWord” filename
Display only those line containing string
grep -c “searchWord” filename
Display no. of matched Line (only Number)
grep -h “searchWord” filename
Display matched lines, but do not display filename
grep -i “searchWord” filename
Ignore case sensivity
grep -l “searchWord” filename
Display filenames, but do not display matched lines.
grep “.*xyz” filename
display lines containing only words ends with xyz
grep “[aeo]gg” filename
u want to search egg but not sure about first letter may be a,e,o but sure about gg next two words
grep “...ya” filename
if not sure about first three letters (may be tanya, divya)
grep “a*vinash” filename
after a appearance or a zero or more characters ex. aaaavinash and also can avinash
grep “^an” filename
match line begin with “an” → i.e. (anusha, anurag, anil)
grep “sh$” filename
match line ends with “sh” → i.e. (avinash, akash)
grep -n “searchWord” filename
Display matched line and their line numbers
grep -v “searchedWord” filename
Display all lines that do NOT match
grep -w “searchedWord” filename
Match Whole Word
# awk utility → pattern scanning and processing language.
egg order 4
cake good 10
cheese okay 4 filename → inventory
pen good 12
floppy good 5
*awt '/good/ {print $1 “ - “ $3}' inventory
: print searched word field 1 – field 3
output : cake – 10
pen – 12
floppy -5
*awk '/egg/ {print $0} /cake/ {print $0}' inventory
: print for two search words egg and cake & show all fields
output : egg order 4
cake good 10
# sed utility → stream editor for filtering and transforming text
sed '/egg/s//chicken/g' inventory
Substitute(s) all occurrence of egg to chicken globally(g) for inventory file
sed -n [commands]
Suppress to display output of result
Coding, Programming examples using amazing small applications only for educational purpose.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment