mcgwier
3/24/2015 - 7:00 PM

useful linux commands

useful linux commands

#Copy directory to remote server from remote server
scp -r sourcedir/ user@dest.com:/dest/dir/

#Create Symbolic link(Short cut)
ln -s /source/dir destination/dire/short_cut_name
ln -s -f /source/dir destination/dire/short_cut_name
 
#truncate a file(0 means how many character you wanna keep)
truncate -s0 /path/to/file
 
#see a file's last portion on real time
tail -f path/to/file
 
#See a folder's size
du -hs /path/to/folder
 
#See a file size
du /path/to/file -h
 
#See full disc size
df -h
 
#Search file with pattern and delete them (from a specific directory)
find . -name 'file_name_pattern*' -delete
find . -name '*file_name_pattern' -delete
 
#find running process and kill them by process id forcefully
ps aux | grep rails
kill -9 RAILS_PROCESS_ID
 
#Zip a folder
zip -r new_zep.zip /folder/path
 
#untar a gz file
tar -xvzf file.tar.gz
 
#Remove recursively a folder's content(keeping the folder itself)
rm -rf /path/to/folder/*
 
#Download
wget download_url -O new_downloaded_file_name
 
 
#Copy a folder
cp -r  source/dir destination/dir
 
#To know 32 or 64 bit Linux machine
uname -a
 
#To know Ubuntu version
lsb_release -a