Linux Commands

Check the system kernel version:

uname -a
cat /proc/version
lsb_release -a

To copy a folder and exclude a folder within. I use to this to copy git project from place to another git server.

rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude
rsync -av --progress source/ path/to/dest/ --exclude .git

Check display settings:


View Bootup messages:


Test DNS:


ex: nslookup

Diff between two folder to create patch:

Create a file (ignorefile) that contains file patterns to ignore:

diff -X ignorefile -rupN original/ new/ > original.patch
 -r When comparing directories, recursively compare any subdirecto- ries found. -u Use the unified output format. -p Show which C function each change is in. -N --new-file In directory comparison, if a file is found in only one direc- tory, treat it as present but empty in the other directory. --exclude=pattern When comparing directories, ignore files and subdirectories whose basenames match pattern.

When using –exclude, put only the subfolder name, not the entire path.

For instance, when comparing linux kernel, if want to exclude /arch/alpha do –exclude=alpha; –exclude=/arch/alpha does not work


Find file:

find [path location] -[name|iname] "search term"


find . -iname "gli"   - find file case insensitive from current path gli

find / -name "glu*"   - find file case senstive from '/' path of all files starting with 'glu'

Find file by time (src: coderwall)

find . -mmin 

find . -mmin -5       modified in last 5 min

find . -cmin/ctime                         - created in min/days

find . -amin/atime                         - accessed in min/days


Searching for a string in a file:

grep "search_string" filename        - search string in file
grep -w "search_string" filename     - Search for whole words only
grep -i "search_string" filename     - case insensitive
grep -r "search_string" *            - Searching in all files recursively
grep -r "search_string" --exclude="*.sql" *   - Search exclude *.sql files 
grep -r "search_string"  --exclude-dir={"folder_1","folder_2"} *  - Search exclude multiple folders 
grep -r -i --include \*.js --include \*.php "search_string"        -i - case-insensitive search  --include=\*.${file_extension} - search files that match the extension(s) or file pattern only 


Size of current folder: CodeCofee link

du -sh                # disk usage of current folder
du -shc *             # disk usage of all top level directories + total sum
du -hc --max-depth=1  # disk usage of all top level directories + total sum


svn revert -R .     - Revert all changes in current folder and subfolders link

To check out CPU utilization and memory utilization:


Common Tar commands:

tar zcvf archive.tar.gz
tar jcvf archive.tar.bz2

# Extract tar into a specific folder
tar xvf archive.tar.gz -C 
tar -tvf file.tar.gz # list the contents of .tar
tar -ztvf file.tar.gz # list the contents of .tar.gz

tar zcvf archive.tar.gz . --exclude=folder1 #This will exclude folder1 (NO /)

To tar up a rootfs link
cd rootfs
sudo tar cvf /lxcrootfs.tar --exclude='lxcrootfs.tar' .

Change the achieve folder structure
cd my_directory/ && tar -zcvf ../my_dir.tgz . && cd ..

  • unzip
unzip <FILE>.zip -d <DIRECTORY>
unzip -d /opt/


Add user to existing group

sudo adduser

Change user’s primary group
sudo usermod -g

To replace a file in the archive, you must delete the file from the archive and then add it:tar –delete -f archive.tar filetodelete
tar -rvfI don’t even understand these commands anymore
tar jcvf archieve.tar.bz2 -C .
For when you want to do
In the tar you want it to be file1, file2 not /path/to/archieve/file1,/path/to/archieve/file2
tar jcvf archieve.tar.bz2 -C /path/to/archieve .

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s