Linux terminal: Available space on harddrive

df -h

Example output

Tags linux terminal

Linux terminal: Create hierarchy of folders

mkdir -p files/{css,js/{custom,external},fonts}

The above command will create a file structure as shown below. Cool if you need to create the same folder structure over and over - or dynamically. The -p stands for parent and the flag is defined as no error if existing, make parent directories as needed in the man pages.

└── files
    ├── css
    ├── fonts
    └── js
        ├── custom
        └── external
Tags mkdir linux terminal

Check if package is installed on Ubuntu

$ sudo apt-cache policy <package name>


$ sudo apt-cache policy drush
  Installed: 5.8-1
  Candidate: 5.8-1
  Version table:
 *** 5.8-1 0
        500 http://dk.archive.ubuntu.com/ubuntu/ raring/universe amd64 Packages
        100 /var/lib/dpkg/status
Tags ubuntu linux terminal package

Search recursive in files from terminal

grep -r "word or phrase" ./

To show only filenames add -l flag:

grep -lr "word or phrase" ./
Tags terminal linux grep search

Check if package is installed on CentOS

rpm -q <packagename>


rpm -q iptables
Tags centos terminal linux

Screenshot via terminal command

$ xwd > name.dmp

Run in terminal and click a window. A screenshot of the window will be saved to name.dmp

Tags terminal linux screenshot

Add time to terminal

!Disclaimer: I'm not an expert on the .bashrc file, so I can't guarantee nothing will break.

In linux you can make the system show the time as part of the terminal line like this:

[18:15] tss@localhost:~$

To achieve this on Ubuntu* you need to update the ~/.bashrc file.

First take a backup of the file - so you can revert something goes wrong.

$ cp ~/.bashrc ~/.bashrc.bak

Then update the file ~./.bashrc where it says the following (for me it was from line 60)

Tags ubuntu time terminal

Time in Ubuntu prompt

Run the following command in terminal

$ export PROMPT_COMMAND="echo -n \[\$(date +%H:%M:%S)\]\ "

Tags terminal