Posts

Showing posts with the label Command Line

[HOW TO] Find which package includes a specific file

apt-file is a command that allows you to find which package includes a specific file. It can also be used to list all files included in a package without installing or downloading it. Install Open a terminal window and run: sudo apt-get install apt-file -y && sudo apt-file update The last part of the above command will update apt-file 's cache, so it might take a few minutes to complete. Usage The updated cache can be queried for a list of packages containing a file. The query may be constructed using only the file's name or the file's path: apt-file search filename apt-file search path/to/filename The contents of a package can be listed with: apt-file list packagename References apt-file | manpage

[COMMAND LINE] Display structure of directory hierarchy

Let's say you're working on the terminal and want to display current's directory hierarchy in a tree structure, like this: $ tree.sh .kde/share/apps/krita/ /home/wilson/.kde/share/apps/krita . |-paintoppresets |-templates |---CMYK |---Ink |---WS |-workspaces I found the command below on the web and its author even provided it as a shell script to use it easily. ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' Install system wide Open a terminal window and run: dst="/usr/local/bin/tree.sh" && sudo wget http://goo.gl/z8exN -O $dst && sudo chmod +x $dst Install for current user This will install the script for your user only and assumes you have a bin directory on your home directory and it has been added to $PATH . Open a terminal window and run: dst="$HOME/bin/tree.sh" && wget http://goo.gl/z8exN -O $dst ...

[HOW TO] Read/Write clipboard from command line

xsel is a program that allows X selection manipulation, and it can also be used to manipulate clipboard contents. Read clipboard Open a terminal window and run the command bellow. The -b options tells xsel to operate on the CLIPBOARD selection and the -o is used to write the selection contents to standard output. xsel -b -o Write clipboard Using the -i , xsel reads from the standard input into the selection, so for instance, the output of the echo command can be piped into xsel thus set the clipboard contents. Replace CB_DATA with is a string for clipboard data. echo CB_DATA | xsel -b -i Example (write) echo "Xubuntu Geek" | xsel -b -i References xsel manpage

Count number of characters in file from command line and Vim

The command wc prints several file statistics: bytes, lines, words, etc. Using the -m option we can count the number of characters in a text file. Install Open a terminal window and run: wc -m FILE We can count the number of characters from Vim editor using this ex command: :!wc -m % References wc(1) - Linux man page

[HOW TO] Find the process ID (PID) of a running program

The command pidof allows to find the process ID (PID) of a running program. All that's necessary is to supply the program name/command. Example Here we're trying to determine the PID for the Chromium browser. Two processes were found: $ pidof chromium-browser 4639 4637 References pidof(8) - Linux manpage

Show distribution information from command line in Xubuntu

lsb_release prints distribution information. Some examples Open a terminal window and run: $ lsb_release -i Distributor ID: Ubuntu $ lsb_release -d Description: Ubuntu 12.04 LTS $ lsb_release -r Release: 12.04 $ lsb_release -c Codename: precise # Options can be combined (-s for short format) $ lsb_release -sirc Ubuntu 12.04 precise References lsb_release(1) - Linux man page

Bash ternary operation

Ternary operation allows to assign a variable one of two values depending on the evaluation of a Boolean condition. It's also known as conditional operator and inline if. In several programming languages it's expressed using the ?: operator: assign_condition ? value_if_true : value_if_false Bash ternary operation (works for numeric and string conditions) [ condition ] && variable=value_if_true || variable=value_if_false Example b='aaa'; c='bbb'; d [ b == 'zzz' ] && a=1 || a=0 # 0 is assigned to a Bash ternary operation for numeric conditions only (( assign_condition ? value_if_true : value_if_false )) Example b=3; c=10; d=7 (( a = b References Ternary operator in Bash (stackoverflow) ?: operator at Wikipedia Ternary operator in bash

Optimize PNG file size with optipng

optipng is an advanced optimization program for Portable Network Graphics (PNG). It optimizes PNG files, reducing their size without losing any information. Install Open a terminal window and run: sudo apt-get install optipng -y Optimize optipng provides more advanced usages, but to reduce the image size, simply invoke optipng with the image name as its argument. The modification is done in place, ie, the changes are applied directly to the image without creating a backup (if you wish to keep a backup supply the -keep option). Example: optipng image.png References optipng(1) - Linux man page A guide to PNG optimization

xfconf-query set an array value to a property

"Xfconf-query is a Command Line Interface (CLI) tool for accessing configuration data stored in Xfconf." If a property is an array of values: xfconf-query -c CHANNEL -p PROPERTY [-n] -t TYPE1 -s VALUE1 -t TYPE2 -s VALUE2 ... References Xfconf-query

Safely remove USB drive from command line

Open a terminal window and run (replace sdc with the appropriate device): udisks --unmount /dev/sdc1 && udisks --detach /dev/sdc Tip You can find the device name using the mount point (replace MOUNT_POINT with the appropriate mount point, eg, /media/disk): grep MOUNT_POINT /etc/mtab References command line alternative for "Safely Remove Drive" at Ubuntu Forums

[HOW TO] Create cbz file from command line

Open a terminal window, change current directory to the directory where the jpeg files are located and run: zip filename.cbz *.jpg References http://en.flossmanuals.net/e-book-enlightenment/making-cbzs/

Install tilda (pop-up terminal) on Xubuntu

Image
Tilda is a terminal emulator that can be accessed using one keystroke, popping-up like a Quake terminal. Install Open a terminal window and run: sudo apt-get install tilda Run Hit Alt+F2 and type: tilda. Once tilda is running, hit F1 to open the terminal pop-up. Suggestions Add tilda to startup and type this as the command: tilda -h Open a new tab hitting Ctrl+Shift+T and change tabs using Ctrl+PageUp/Ctrl+PageDown If you like the wallpaper, check out: Wilson's Sketch Blog References Tilda Documentation Related Posts Add application to Xfce/Xubuntu session startup