Monday 24 July 2017

Bash Shell commands

CTRL L = Clear the terminal
CTRL R = reverse search history
!! = repeat last command 

ls -a = list all files and folder
du -h: Disk usage of folders, human readable
pwd = print working directory
ln file1 file2 = physical link
ln -s file1 file2 = symbolic link

Search from file Size (in ~)
    find ~ -size +10M = search files bigger than.. (M,K,G)

To text see files ..cat {file name }
      $ cat myfile .....
To display file one full screen at a time
  more {file name }:  $ more myfile

To See more about currently login person (i..e. yourself)
 $ who am i

To get information about all running process
 $ ps -ag

To stop any process i.e. to kill process kill {PID} 
$ kill 1012 

For background processing (With &, use to put particular command and program in background) linux-command & 
$ ls / -R | wc -l & 

> Redirector Symbol....To output Linux-commands result to starting from file.
$ ls > myfiles

>> Redirector Symbol....To output Linux-commands result to END of file.
$ date >> myfiles

< Redirector Symbol....To take input to Linux-command from file instead of key-board
$ cat < myfiles

ls -l | wc -l 
Here output of ls command is given as input to wc command So that it will print number of files in current directory. 

Use chmod command as follows to give execution permission to our script
chmod 777 shell-script-name

 

No comments:

Post a Comment