Search

Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Unix alias

The alias command can be useful if you want to create a 'shortcut' to a command.
The format is alias name='command'


Example:
alias list='ls -la'

To make alias permanent put it in file ~/.bashrc (the file may not exist).
Restart bash with
source ~/.bashrc

Run command./process or execute shell script using nohup

nohup allows to run command./process or shell script that have to  continue running in the background after you log out from a shell.

nohup command-name &
  • command-name : is name of shell script or command name. You can pass argument to command or a shell script.
  • & : nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an & symbol.


Tar/UnTar file and directory

#Tar file
tar -cvf file.tar myfile.txt

#Tar directory 
tar -cvf home.tar directory/

#UnTar tar file 
tar -xvf myfile.tar

#UnTar tar.gz file 
tar -xvzf myfile.tar.gz

#UnTar tar directory 
tar -xvf myfile.tar

#UnTar tar.gz directory 
tar -xvzf myfile.tar.gz

Copy file scp

#Copy file
scp localFile user@host:/.../remoteFile

#Copy directory 
scp -r localDir user@host:/remoteDir