Skip to content

Instantly share code, notes, and snippets.

@nadeem-khan
Last active September 10, 2018 12:40
Show Gist options
  • Save nadeem-khan/bb87a953036b5f8f1e1e to your computer and use it in GitHub Desktop.
Save nadeem-khan/bb87a953036b5f8f1e1e to your computer and use it in GitHub Desktop.
Common Server Related Linux Commands.md

Generic commands

find -name skype
whereis drush
sh file.sh //(installing .sh files)
cat file.txt //(open file)
touch file.txt //(creates an empty file)
makedir -p abc/def/ghi //(will make all folders)
less etc/file.txt
echo $PATH
man chown
ifconfig
ps -aef || grep -i skype
kill <pid>
rsync -avz [email protected]:test/sites/default/files sites/default/files
scp source_file_name username@destination_host:destination_folder

How can I copy the contents of a folder to another folder in a different directory using terminal?

cp -a /source/. /dest/

PERMISSIONS

chown -R nk:nk ./
chmod a+w OR o+w var/html

SSH KEYS

ssh-keygen (for generating new SSH)
cat ~/.ssh/authorized_keys 
cat ~/.ssh/id_rsa.pub (for getting machine finger print or ssh key)

Virtual Hosts

sudo emacs /etc/hosts
sudo emacs /etc/httpd/conf.d/arkhitech.conf OR sudo gedit /etc/apache2/sites-available/default
less /var/log/httpd/

Restart Commands

 sudo /etc/init.d/apache2 restart
 sudo apache2ctl restart
 sudo restart apache2
 sudo service apache2 start
 //if nothing working then do sudo su - first and then try
 //count the lines in a file
 wc -l dev.sql   

Search in running processes and the kill some process

ps -aef |grep sear
kill 6775

Console Shortcuts

 shift+g => to go to file end
 ctrl + r => to do reverse search

Cron Jobs // list all cron jobs for user apache sudo crontab -u apache -l

// see disk usage overall sudo du -cha --max-depth=1 / | grep -E "M|G" sudo df -h (shows in human readable form)

Tools iotop (to check realtime i/o overview) - sudo apt-get install iotop ncdu (to check disk space usage of any directory) - sudo apt install ncdu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment