Handy Linux Commands

Get the size of the folders in any directory

du -sh folder_location/*

Get the size of folders in the current directory

sudo du -chax --max-depth=1 . | grep -E "M|G"

Search for content of a file from the command line

grep [--include=file_pattern.extension] -rnwl "matching pattern"
http://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-on-linux

Create a new SVN Repo

sudo svnadmin create /svn/repos/repo_name
sudo chown -R www-data:www-data /svn/repos/repo_name

Remove Directory and Contents

rm -r mydir

List CPU Usage of running processes

top

Get Wireless Signal Information

iwconfig

will save in /tmp/file_list_$FOLDER an alphabetically ordered list of all the files inside $FOLDER, complete with the corresponding sub-folders

find $FOLDER -type f | cut -d/ -f2- | sort > /tmp/file_list_$FOLDER

Display all processes accessing a folder or drive (source)

sudo fuser -mv /folder

zpool change mount location (source)

zfs set mountpoint=/myspecialfolder mypool

lsof command to get the process ID of the process holding the lock files (source)

sudo lsof /var/lib/dpkg/lock
sudo lsof /var/lib/apt/lists/lock
sudo lsof /var/cache/apt/archives/lock

Get all processes running “apt” and kill those processes (source)

ps aux | grep -i apt
sudo kill -9 <process_id>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.