Useful Linux Commands

This is a compilation of rather rare, useful Linux Commands.

  • mount remote folder using sshfs
  • sshfs example.com:/stuff /media/music
    (unmount “fusermount -u /media/music”)

  • scan for wireless networks
  • iwlist eth1 scanning (replace eth1 with your interface)

  • backup mysql database and compress backup file
  • mysqldump -ppassword -uuser -phost database_name | gzip > backup_name.sql.gz

  • check disk space
  • df -h

  • display connection count by ip address
  • netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr

  • mount network share
  • sudo mount -t smbfs //san/ics /mnt/ics -o username=user,password=pass

  • find files modified recently
  • find . -mtime -1
    (find all files in the current directory and subdirectories, modified within the last 24 hours)
    find ~ -mmin -90
    (find all files in the home directory, modified within the past 90 minutes)
    find ~ -type f -mmin -90 | xargs ls -l
    (same as above, but with extended output information)

  • find text within files and display file names only
  • find . | xargs grep ’string’ -sl
    (-s is for summary and won’t display warning messages, -l is for list, so we get just the filename)

  • retrieve OS version and Kernel info
  • uname -a print all information
    uname -r print kernel release
    uname -v print kernel version and info

  • delete all .svn files and folders
  • find . -name .svn -print0 | xargs -0 rm -rf

  • MySQL auto repair, check and optimize all the tables on all databases running on a  server
  • mysqlcheck -u root -p password –auto-repair –check –optimize –all-databases

If you know some exotic but useful unix commands, we’d be happy to add them. Simply drop us a line: submit@itecsoftware.com

  • Digg
  • Facebook
  • Twitter
  • StumbleUpon
  • Windows Live Favorites
  • Yahoo Buzz
  • Share/Bookmark