Skip to content

Instantly share code, notes, and snippets.

@akmur
Forked from barek2k2/Most used linux command
Last active December 22, 2015 17:59
Show Gist options
  • Save akmur/6509410 to your computer and use it in GitHub Desktop.
Save akmur/6509410 to your computer and use it in GitHub Desktop.
Useful Linux Commands in collaboration with Abdul Barek
Copy directory to remote server from remote server
scp -r sourcedir/ user@dest.com:/dest/dir/
Run a scheduled rake task(lets say update sphinx indexing on every 30 min periodically) on Lunux crontab:
# find where is your rake(which rake)
#m h dom mon dow user command
*/30 * * * * root /bin/bash -l -c 'searchd --stop -c /var/rails/project/current/config/production.sphinx.conf && cd /var/rails/project/current && RAILS_ENV=production /usr/local/bin/rake ts:rebuild && chmod -R 777 tmp/'
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment