Basic Linux commands for myself

  • sudo reboot -> reboots system
  • sudo shutdown -h now ->poweroff system
  • service mysql restart -> restart mysql service
  • service apache2 start -> start apache service
  • service apache2 status -> apache service status
  • zip -r file.zip /folder -> zip a folder recursively
  • unzip file.zip -> unzip a a zip file
  • du -hs /folder -> determine a folder’s size -h human readable -s summary
  • chown owner:group tmpfile -> Change both owner and the group of a file
  • Add a cronjob that runs ever five minutes
    PATH=/usr/sbin:/usr/bin:/sbin:/bin
    */5 * * * * service mysql start
  • Create a user account
    useradd username
  • Change password of a user
    passwd username
  • Rename a folder mv /home/user/oldname /home/user/newname
  • Install updates sudo apt-get update # Fetches the list of available updates sudo apt-get upgrade # Strictly upgrades the current packages sudo apt-get dist-upgrade # Installs updates (new ones)
  • Copy file
    cp -i /home/mkavici/file.txt /media/sda3/Dropbox/
  • Move a file
    mv file.txt folder/
    *Download a file
    wget https://…
  • Find all files larger then 49 bytes find /home/admin/web/kavici.com -type f -size +49b -exec ls -lh {} \;
  • Disk usage: df -h