*********************************************************************** SYSTEM-INFO-COMMAND
***********************************
*How to play a songs through command mode
#yum install cmus
#cmus
- press no. '5' to select the songs dir.
- press '+' to increase the volume .
- press '-' to decrease the volume.
- press 'right arrow' to forward the song.
- press 'left arrow' to rebind the song.
& more option to play "cmus" command
How to run Google Chrome as root.
Right click on the launch icon and select properties. Append the following to the command in the
#launcher --user-data-dir
This is what it will look like
/opt/google/chrome/google-chrome %U
just change it to be
/opt/google/chrome/google-chrome --user-data-dir %U
If you can’t find the launcher then you have to add it to panel or to your desktop. Select Applications-->Internet-->Google Chrome, right click on it and select Add this launcher to panel or Add this launcher to Desktop. Once you find the launcher icons, follow the steps above to run Chrome as a root user.
--------------------------------------------------------------------------------------------------------------------------
1. #cat sl-60-x86_64-2011-live-DVD.iso >> /dev/sdb1 or /dev/cdrw
(To make a live booting USB/CD/DVD from linux command mode )
2. #partprobe /dev/sdb1 [so kernal can read this pendrive as bootable device]
-----------------------------------------------------------------------------------------------------------------------------
Keyboard Shortcuts
*******************
Enter – Run the command
Up Arrow – Show the previous command
Ctrl + R – Allows you to type a part of the command you're looking for and finds it
Ctrl + Z – Stops the current command, resume with fg in the foreground or bg in the background
Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line
Ctrl + L – Clear the screen
command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow
!! – Repeats the last command
command !$ – Repeats the last argument of the previous command
Esc + . (a period) – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command
Ctrl + A – Return to the start of the command you're typing
Ctrl + E – Go to the end of the command you're typing
Ctrl + U – Cut everything before the cursor to a special clipboard, erases the whole line
Ctrl + K – Cut everything after the cursor to a special clipboard
Ctrl + Y – Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
Ctrl + T – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)
Ctrl + W – Delete the word / argument left of the cursor in the current line
Ctrl + D – Log out of current session, similar to exit
----------------------------------------------------------------------------------------
Learn the Commands
********************
apropos subject – List manual pages for subject
man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes
whereis app – Show possible locations of app
which app – Show which app will be run by default; it shows the full path
--------------------------------------------------------------------------------------------------------
Searching
************
grep pattern files – Search for pattern in files
grep -r pattern dir – Search recursively for pattern in dir
command | grep pattern – Search for pattern in the output of command
locate file – Find all instances of file
find / -name filename – Starting with the root directory, look for the file called filename
find / -name ”*filename*” – Starting with the root directory, look for the file containing the string filename
locate filename – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
updatedb – Create or update the database of files on all file systems attached to the Linux root directory
which filename – Show the subdirectory containing the executable file called filename
grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containing TextStringToFind
---------------------------------------------------------------------------------------------------------
File Commands
***************
ls – Directory listing
ls -l – List files in current directory using long format
ls -laC – List all files in current directory in long format and display in columns
ls -F – List files in current directory and indicate the file type
ls -al – Formatted listing with hidden files
cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory
rm name – Remove a file or directory called name
rm -r dir – Delete directory dir
rm -f file – Force remove file
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)
cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn't exist
cp file /home/dirname – Copy the file called filename to the /home/dirname directory
mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2
ln -s file link – Create symbolic link link to file
touch file – Create or update file
cat > file – Places standard input into file
cat file – Display the file called file
more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Output the first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines
----------------------------------------------------------------------------------------------------------
Compression
**************
tar cf file.tar files – Create a tar named file.tar containing files
tar xf file.tar – Extract the files from file.tar
tar czf file.tar.gz files – Create a tar with Gzip compression
tar xzf file.tar.gz – Extract a tar using Gzip
tar cjf file.tar.bz2 – Create a tar with Bzip2 compression
tar xjf file.tar.bz2 – Extract a tar using Bzip2
gzip file – Compresses file and renames it to file.gz
gzip -d file.gz – Decompresses file.gz back to file
-------------------------------------------------------------------------------------------
Printing
*************
/etc/rc.d/init.d/lpd start – Start the print daemon
/etc/rc.d/init.d/lpd stop – Stop the print daemon
/etc/rc.d/init.d/lpd status – Display status of the print daemon
lpq – Display jobs in print queue
lprm – Remove jobs from queue
lpr – Print a file
lpc – Printer control tool
man subject | lpr – Print the manual page called subject as plain text
man -t subject | lpr – Print the manual page called subject as Postscript output
printtool – Start X printer setup interface
-----------------------------------------------------------------------------------------
Stopping & Starting
**********************
shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system
-----------------------------------------------------------------------------------------
ssh -p port user@host – Connect to host on port port as user
ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login
------------------------------------------------------------------------------------------
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
*Note :- Mostly commands work under the these 'dir' - /bin
/bin/bash
/usr/bin
/sbin
/usr/sbin
/etc
* on sudo this work like this - #sudo /sbin/ifconfig
$locat command name [ to find the location of the command like - /sbin/init , /sbin/adduser ]
$whereis command name [ to fined the location of the command and find any file and dir from the system ]
$xclock [ to show gnome clock ]
$oclock [ " ]
$du -h [ find the used disk in GB ]
$df -h [ find the free space in hard disk ]
$du -sh name of file/dir [ to find the particular file/dir used space ]
$ls -m [ to find vertical width with sepretcomma,]
$ls -m -u [ list info about mostly used file/dir ]
$umask -s [ default permission of file/dir ]
$chage -l user-name [ show account ageing info ]
$lsof [ list of open file ]
$rpcinfo [ report RPC information ]
#iptables -L -n -v [ display the status of your firewall ]
$env [ display the environment of your system ]
$dmidecode [ all about the BIOS]
$biosdecode [ all about the BIOS ]
$chkconfig --list |less [ find the all running services ]
# mpstat 2 5 [ Report processors related statistics & to find out all the processing is runnig ]
$ps -avx [ runing process ]
$uptime [ find the total hour of system is up ]
$pwd [ to find out the location of the present currsor ]
$last [ show listing of last logged in users ]
$lastb [ show listing of last bad password used by other user ]
$lastlog [ reports the most recent login of all users or of a given user ]
$lastcomm [ print out information about previously executed commands ]
$last -d [ For non-local logins, Linux stores not only the host nameof the remote host but its IP number as well. This option
translates the IP number back into a hostname.]
$last -a [ Display the host-name in the last column. Useful in combination with the next flag.]
$last -F [ Print full login and logout times and dates.]
$last -o [ Read an old-type wtmp file (written by linux-libc5 appli-cations)
$last -w [ Display full user and domain names in the output.]
$last -x [ Display the system shutdown entries and run level ]
$arch [ to find out bit size of os ]
$uname -rmi [ "]
$cat /etc/redhat-release [ to find out about OS ]
$ksnapshot [ to take a snapshot ]
$lspci [ list of all PCI devices ]
$lspci |grep ethernet [ to find out the Ethernet devices ]
$ls -lZ [ to find out the SElinux context ]
#getenforce [ show the selinux status ]
#setenforce 0 [ off selinux]
#serenforce 1 [ on the selinux]
#vim /etc/sysconfig/selinux [ to change selinux value from the vim editor mode ]
#vim /etc/selinux/conf
#getsebool -a [ get SELinux boolean value(s) ]
#getsebool -a |grep samba
#setsebool [ set SELinux boolean value ]
#setsebool -p on
#setsebool -p of [ we can also use 0 and 1 on the place of 'off' and 'on' ]
#vim /etc/hosts.allow [ Make entry the name of host that should be allow to access and use our server ]
ex. - vsftpd: 192.168.1.0/24
EXCEPT 192.168.1.2
OR
vsftpd : ALL EXCEPT 192.168.1.2
:wq [ save the file ]
#vim /etc/hosts.deny [ deny the users that should not use the service ]
Ex. - sshd: all except 192.168.1.0/24 except 172.16.0.0/24
:wq [ save the file ]
#set |less [ show all information of user ]
$press 'ctrl + m to use Enter key
$press 'ctrl + p to find the history
$fc -l [ to see the history
$sar [ Collect, report, or save system activity information ]
$sar -n dev |more
$sar 4 5
* Binary Marks
--------------
Digits Permission
0 none
1 execute
2 write
4 read
3 (1 +2 ) write and execute
5 (1 + 4 ) read and execute
7 (1 + 2 + 4 ) read , write and execute
-----------------------
*USERS INFORMATIONS
--------------------
$cat /etc/passwd [ all users informations ]
$cat /etc/shadow
$cat /etc/gshadow
$cat /etc/group
--------------------
#chage -l username [ change user password expiry information ]
#vi /etc/sysconfig/selinux [ configure ther SElinux configuration]
#cd /var/log [ to check the log file ]
#log] tail messages [ to check the massages ]
#log] tail secure [ to check about the security log ]
#ls -ltr [ to check all log file ]
#who -b [ show the dat and time of last system boot]
#who - u [ where (.) means the user was active in the last minute , (old) means the user has been idle for more than 24 hours ]
#who -m [ show only hostname ]
#date --date='15yers ago' [ show the same day before 15 years ]
#setfont /lib/kbd/consolefonts/iso02-12x22_press-tabe [ to set the font of the console or command mode ]
#cat OS.iso >> /dev/sdb1 [ To make a live booting from linux usb ]
#partprobe /dev/sdb [ So kernal can read this pendrive ]
#startx [ To go from command mode to graphic ]
#last username [ To find last login by user ]
#set |less [ To show the all information about user ]
#!any-word [ To find the history by that word ]
========================================================================
----------------------------------------------------------------------------------------------------------------------------------
vimtutor (all editor - 'vi' 'vim' 'gvim' 'gedit' 'nano' 'emac' 'joc' 'cat' )
--------------------------------------------------------------------------------
'VIM' Editor
..........................
#vim file-name
*press 'I' 'A' 'O' 'S' and 'P' to go in to the insert mode ( to write some thing in the fiel )
*prss 'Esc' key to exit from the insert mod
*press ' :wq ' to save and quite from the file
*press ':q' to quit from the file
*press ':q!' to quit forceful
*press ':w' to save the file
*press ':w!' to save forcedly
*press ':wq!' to save and quit forcedly
*press 'd' to delete the line
*press '2dd' two line delete '3dd' three line delete
*press 'x' to delete the one by one
*press 'e' to end of the line and move right side
*press '0' to go to the first word of the line
*press 'y' from the word we want to copy [y - means yenky ] copy one line,
*press '2yy' copy to line . press '3yy' copy three line
*press 'p' to past the line
*press ':set nu' to set the all line in numbering.
*press ':set nonu' to set no numbering
*press ":! any command" we can run any command while using 'VIM' run any command under the vieditor
----------------
* To move the cursor, press the h,j,k,l keys as indicated. **
^
k Hint: The h key is at the left and moves left.
< h l > The l key is at the right and moves right.
j The j key looks like a down arrow.
v
*press 'dw' to delete a word
*press 'u' to undo the deleted line & press 'U' to undo whole line
*press 'Ctrl + r' to redo the command and word
*Type ' r ' and then the character which should be there ( to replace the word )
*Type "CTRL-G" to show your location in the file and the file status
*press 'gg' to go on the TOP of the page
*press 'Shift + g' to go on the BOTTOM of the page
*press "/word to find" to find any word in the page
*press " :25 " to go on the 25th line means find the sentence by the number
*To Replace the word run this command :- " :%s/Rahul/Amit/g " means Rahul has been replaced by Amit.
*To copy from the working file to a new file in vim editor use this command ( :!cp running-file-name any-new-file-name )
#chattr
+i file name [ 'chatter' attribute is used to stop
accidentally deletation of files and dir. we can not delete the files
secured via
------------------------- 'chattr' now we can only read by option (+i) to remove the premission use (-i)
#chattr -i file name [ to remove the permission ]
-----------------------
$grep word-name file/dir [ to find start from this word ]
$grep -i word-name file/dir [ "]
$less
file-name [ to view the file step by
step press 'v' to open the vieditor to change something ]
CAT-Editor
--------------------------
$cat
> ram [ to create a new
file 'cat > ram press enter and start to write after finished
press 'Ctrl+D' to save the file ]
- - - -- -- - -
--- -----------
----------^D [ to save the fiel ]
$cat ram sam [ to show the both file one time ]
$cat ram sam > gopi [ to send the all content of 'ram' and 'sam' into the 'gopi' ]
$cat ram [ show the file ]
$cat >> ram [ to add some word and sentence in ram file ]
$cat -Et ram OR $cat -A ram [ to show the end of file ]
---------------------------------------------------------------------------------------------------------------------------------