basic commands
$ lshw
$ lsusb
$ lspci
$ lsblk
will list the hardware devices and their properties
$ checkbox-gtk
complete gui based ubuntu machine trouble shooter.
$ apport-bug audio
a ubuntu UI-based trouble shooter.
$ gconftool-2 --recursive-unset /apps/panel
$ killall gnome-panel
resets all panel setting to defaults values.
$ lsb_release -a
will gives all the information regarding the linux distro and release version
$ groups
will lists all the groups in which user is added
$ groupadd
will create a new group of name "group_name". on succussfull execution the same
name will be displayed in the '/etc/group' file
$ adduser --home "/home/user" --shell "/bin/bash" user
adds a new user of name 'user'
$ deluser --remove-home --force user
deletes a user of name 'jira'
$ echo -e 'user1:user123::::/home/user1:/bin/bash\nuser2:user123::::/home/user2:/bin/bash' | sudo newusers
batch creates multiple users with user123 as password
$ sudo adduser user sudo
add user to sudoers group
$ man builtins
to get the man page of all the bash buildin commands
$ echo "/usr/bin/python" | sudo tee /etc/shells; chsh -s /usr/bin/python
used to change the default shell to python
$ echo $?
prints the return value of the program after executing (like 'ls', 'ls -l' command)
$ echo $USER
prints the string in Envirolmental "USER" variable
$ echo $LINES $COLUMNS
prints the terminal sizes
$ ls / > stdout.txt
$ ls /dir 2> stderr.txt
$ ls / /dir &> stdout_and_stderr.txt (if this not works, use next cmd)
$ ls / /dir 2>&1 | tee stdout_and_stderr
$ ls / /dir >> stdout_and_stderr 2>&1
for directing the outputs into the text files
$ ls / | tee stdout.txt
$ ls /dir 2| tee stderr.txt
$ ls / /dir &| tee stdout_and_stderr.txt (if this not works, use next cmd)
$ ls / /dir 2>&1| tee stdout_and_stderr
prints the outputs onto the console and also redirects the outputs into files
$ id
prints all the info of the user
$ id
print the uid and gid of the current user. Prints 0 for root user.
$ export USER=user
sets the in Envirolmental "USER" variable to "user"
$ env
prints all the Envirolmental variables
$ export PATH=$PATH:/opt/arm-2006q3-27/bin/
adds the path /opt/arm-2006q3-27/bin to PATH env variable.
$ alias ls='ls -aF --color=auto'
make alias name for 'ls' to 'ls -aF --color=auto' for color listing of contents.
keep this command in ~/.bashrc file to run it for every invokution of bash terminal.
$ unalias ls
make 'ls' to default again
$ disown
releases all the background processes which are cloned from the present shell.
otherwise the child processes will also be terminated if we close the shell.
$ sudo remastersys dist
This will create an iso of your current configuration in /home/remastersys/remastersys/nameofyouriso.iso.
Also, be sure you add the following to /etc/apt/apt.conf:
APT::Install-Recommends "0";
APT::Install-Suggests "0";
$ sudo hostnamectl set-hostname user-desktop
change hostname persistantly, if required, add this name beside 'localhost' in /etc/hosts
$ init 1
will take the machine to single user mode.
$ sudo -k
will clear the stored passwd of the bash shell. so for the next time it will surely promts for the sudo promt
$ export IFS=" " # delimiter used by the 'complete' command also
IFS (internal field separator) used by the bash to separate some string options
$ complete -W "option1 option2 option3 ..."
will create option completions when used
$ complete -p
will print all the command completions list.
$ complete -r
will remove the command's option completions from the list
$ echo "text" | xsel
copy a string to the primary clipboard
$ xsel -o
shortcuts: [mouse middle button] or [shift + insert]
pastes the clipboard copied string.
$ gnome-screensaver-command --lock
$ gnome-screensaver-command --activate
$ xdg-screensaver lock
used to lock the screen
$ gnome-screensaver-command --deactivate
used to unlock the screen
$ gnome-screensaver-command --query
query the state of the screensaver
$ system-config-printer
for configuring printers or login to: http://localhost:631/admin/
$ nm-connection-editor
for configuring network manager through gui
$ export DISPLAY=:0.0
$ gnome-shell --replace &
will restart gnome-shell without interrupting the applications
launch these commands from console_1 (alt + ctrl + f1)
$ nmcli con down uuid 2958a863-c599-4f01-81ff-d0b20ff0fae7
to down eth0 interface of the network manager using cli
$ nmcli con up uuid 2958a863-c599-4f01-81ff-d0b20ff0fae7
to up eth0 interface of the network manager using cli
$ ls ~/.vim/{autoload,bundle}
will list file in ~/.vim/autoload and ~/.vim/bundle
$ du -h
prints all files's sizes (in KBytes) in directories and sub-directries
$ du -sh *
prints all directories sizes in MBytes.
$ basename /usr2/c_mk/local/Pictures/films/priyamani.jpg
prints the name of the file 'priyamani.jpg' only excluding all the given path before
the name as the argument.
$ dirname ./films-wallpapers/ileana/ileana_016.jpg
prints the name of the dir as './films-wallpapers/ileana' at which the file exits.
$ ls | wc -l
prints the number of files present in current directory
$ ldd a.out
print shared library dependencies of a.out excutable
$ ldconfig -p
print all the names and fullpaths of linkable libraries
$ sudo chown -R c_mk *
changes the ownership of the all the files to "c_mk" and this command needs sudo permissions.
$ sudo chown -h user:crontab /var/spool/cron/crontabs/user
changes the ownership of the symbolic link file.
$ sudo chown root:root a.out
$ sudo chmod +s a.out
will change the permissons of the file to run as root, when invoked by any user
$ ls / | grep -v root
lists all the folders in / without "root" directory
$ ls -d */
lists only folders in present directory
$ ls -d */*/
lists only the folders which have folders in them.
$ top
it is command to see the load on cpu currently.
$ ps auxg
it gives the name list of all process running presently with their arguments..
$ ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,args
To see every process with a user-defined format.. we can select one or more from the a
$ ps -eo "%p|%P|%r|%C|%z|%c|%a"
will print processes information in the format of "PID|PPID|PGID|%CPU|VSZ|COMMAND|ARGS".
$ ps auxww | awk '$0~/netscape/ && $0!~/awk/ {print $2}' | xargs kill
kills the process with the name, here the example is 'netscape'.
$ echo "sometext" | awk '{printf "%s\n",gensub("text", " text", $0)}'
find and replace sub-strings using awk
$ awk 'NR==2 {print $0}'
will print only second line of the file
$ echo '(234*23)+((34*78)/5)' | bc
calculates the given mathematical expression and prints the result
$ tar cf dir.tar dir/
$ tar czf dir.tar.gz dir/
$ tar cjf dir.tar.bz2 dir/
to create tar files of different types.
$ tar xf dir.tar
$ tar xzf dir.tar.gz
$ tar xvf dir.tar.xz
$ tar xjf dir.tar.bz2
to extract the same in present dir.
$ tar -tvf archive.tar
list all files in archive.tar verbosely.
$ tar -xvf tarball.tar path/to/single_file
extracts only one file from the tar
$ 7z x archive.7z
extracts 7z archives with paths
$ sed -i 's/\x0//g' winCmdOutput.txt
$ tr -d '\0' < winCmdOutput.txt > converted.txt
converts windows cmd directed output files to unix text format
$ fromdos a.txt b.txt
$ dos2unix a.txt b.txt
converts and replaces the both the files form dos text file format to unix text format.
(removes all ^M from the text files).
$ touch file_peru
creates an empty file with name 'file_peru'.
$ grep -o "href=" line.txt | wc -l
counts the no.of times the string present in a file
$ cat file | tr ' ' '\n'
prints every word saparetely on single line.
$ echo '/dev/sda1 /mnt/1cdrive ntfs-3g defaults,posix=1,uid=1000,gid=1000,umask=022 0 0' | sudo tee -a /etc/fstab
fstab entry for ntfs drive mounting
$ nautilus ssh://root@192.168.128.128
$ nautilus smb://netapp-pu/builds_mobile/
mounts the network machine through ssh or samba interface to '$HOME/.gvfs/*' folder
$ smbclient -L fs-hyd-04.ibn.broadcom.net -U user%passwd -W Broadcom.net
will list all the samba mountable paths served by the server
$ sudo mount //10.24.109.72/linuxmounted/ /mnt/windowsMounted -t cifs -o user=user,password=passwd,domain=domain.com,uid=user,gid=user,file_mode=0755,dir_mode=0775,rw
will mount the samba sharing folder in linux
$ sudo umount -t cifs -l /mnt/ushShared
to forcebily unmount the cifs mount if the target machine is down
$ sudo sshfs -o allow_other root@localhost:~/ ./mounted_dir
$ echo 'sshfs#root@localhost:/ ./mounted_dir' | sudo tee -a /etc/fstab
to mount the remote file system via sshfs
$ ssh-keygen -t rsa
$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.128.221
used to do passwd less login to the machine with ip 192.168.128.221
$ ls | paste - file
concatinates ls cmd output and file content
$ md5sum file
returns a unique hash value of the file
$ seq 0 5 100
prints all the numbers from 0 to 100 with constant increment of 5
$ seq -s "=> " 0.0 0.1 2.0
prints all the float numbers from 0 to 2 with increment of 0.1 and saperator string of '=> '
$ tty_settings=`stty -g`
$ stty -echo
$ read passwd
$ stty $tty_settings
these set of cmds will be used to get the unechoed password from the stdin.
$ uniq file
eliminates the similar consicutive lines in a given file
$ sudo hdparm -I /dev/sda
gets all the hard drive parameters from the direct hardware
$ lynx -dump [ link.html | file.html ]
dumps the text data of the html file on to the stdout
$ sudo apt-get update
$ sudo apt-cache search
$ sudo apt-get install
$ sudo apt-get --yes --force-yes install
source list file is at location '/etc/apt/sources.list' and the '.deb' files of newly
installed packages through apt-get will be stored in '/var/cache/apt/archives' dir, but need
to set the APT::Clean-Installed "false"; for syntax of these configs of apt-get see
the file: /usr/share/doc/apt/examples/configure-index.gz
$ sudo apt-cache depends
Display dependencies of package
$ sudo apt-get remove
$ sudo apt-get install
used to unintall the package
$ sudo dpkg-reconfigure gdm
used to reconfigure the gnome-desktop-manager in ubuntu
$ apt-rdepends -p nvidia-319
to print the dependency packages of the given package
$ rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
$ wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
$ rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm
$ rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm
$ yum check-update
to enable the yum utility in the redhat machines
$ rpm -qa
gives the list of all installed packages on the machine
$ rpm -ql
will give the list of all files in package
$ rpm -qf
will give the name of the rpm package to which the file belongs to
$ rpm -qp --scripts mplayer*.rpm
will gives the dumps of pre and post installation scripts
$ rsync -av --delete src/. dest
to rsync two folders in same machine
$ rsync -av --delete src/ user@192.168.128.240:/home/emb/dest
$ rsync -av --delete user@192.168.128.240:/home/emb/src dest
to rsync two folders in two remote machine
$ tr '[[:upper:]]' '[[:lower:]]'
converts upper case to lower case
$ crontab -e
takes you to edits a cron jobs. add a cron job as per the below format.
and this will be stored into the file '/var/spool/cron/crontabs/
for running a job on 04-jan 5:30 AM use below syntax
# Minute Hour Day_of_Month Month Day_of_Week user Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat) () (full path of the command)
30 5 4 Jan * user echo "Happy Birthday!!" | wall
45 12 * * * user DISPLAY=:0.0 notify-send "Hi" "Time to Call"
all cron logs will be there in: /var/log/syslog
for more info on cron config file run: $ man 5 crontab
$ echo 'cat ~/p.py > ~/m.py' | at 2pm tomorrow
$ echo 'cat ~/p.py > ~/m.py' | at 2pm +1 day
$ echo 'cat ~/p.py > ~/m.py' | at 14:00 July 6
$ echo 'cat ~/p.py > ~/m.py' | at 2:00pm Friday
$ echo 'cat ~/p.py > ~/m.py' | at now +5 min
will run a cmd at selected time
$ sudo dpkg -l
will list all the packages which are installed on the system.
$ dpkg -l *
This will find packages whose names contain
but also shows whether a package is installed on your system by marking it with ii (installed)
and un (not installed).
$ dpkg --info package.deb
will print the version and dependency list of the given package
$ dpkg -i
will installs locally exited package
$ dpkg -L
will lists all the files which have been added by that package
$ dpkg -S /bin/netstat
will finds, what package owns the file /bin/netstat
$ sudo dpkg --purge libssl1.0.0:i386
will remove the package completely
$ dd if=/media/dvd/in.mpg conv=noerror of=out.mpg
will copy the file in dvd while ignoring I/O errors.
$ dd skip=1234 count=5 bs=1 if=inputFile
will print file contents from byte 1235 to 1239
$ look
will print all the dictionary occurences of the word
$ wn program -over
will display the meaning of the word 'program' from the english dictonary
$ wn program -grepn
searches similar noun words of 'program' in the dictonary
$ wn program -grepv
searches similar verb words of 'program' in the dictonary
$ btdownloadheadless
$ btdownloadcurses
command line tools to download torrents.
$ fold -w 50 alp_programs/special_commands.txt
wrap each input line to a limited length of 50
$ sudo foremost -t jpg -i /dev/sda5
recovers the jpg files from any mount point [hdd/pendrive] partitions, which
has been deleted by rm command.
$ df -T .
will show full details of the filesystem
$ od -t x1 file.txt
shows the whole file content in hexadecimal form.
$ od -t d1 file.txt
shows in decimal form
$ od -t c file.txt
shows in ascii equavalent form
$ rar e file.rar
will extract the files from .rar archive to current dir.
$ gnome-specimen
font viewer
$ echo "hello" | write user pts/0
will sends a message the 'user' user's 'pts/0' shell
$ echo "hello" | wall
will sends a message all logged-in user's shells
$ mesg n
will disable the messages sent by the above commands
$ ip addr show
will show all the ips currently assigned.
$ nc -l 12345
will start netcat in "listen mode" waiting for a connection on remote machine
$ cat p.py | nc
will instruct netcat to start a connection to remote machine (port 12345)
and send whatever it gets from stdin over the network
$ grep -e "started\.$" /var/log/syslog*
to get the list of system uptimes
$ grep "word" -A 1 file.txt
prints matched line and one trailing line from the file
$ grep "word" -B 1 file.txt
prints matched line and one leading line from the file
$ grep "word" -C 1 file.txt
prints matched line and one leading and trailing line from the file
$ stat -f .
displays the filesystem of the current dir
$ rm -fr -- -c
to delete a file with filename starting with '-'
$ zip outFile.zip
will zip the list_of_files into outFile.zip
$ sudo netstat -tulpn
will list all open listening ports with their processes pids
$ tracepath google.com
will trace the packet routes
$ nslookup google.com
will give the dns server from which google.com got resolved
$ lsof -ni
will list all the socket connections
$ watch -n 2 ls *
will repeats the command 'ls' for every 2 seconds
$ free
will show the ram and swap memory status
$ scp user@host:/{path1,path2}
will copy multiple files from same remote host
$ pdfseparate src.pdf dst_%d.pdf
will separate all the pages of src pdf into multiple pages
$ pdfunite src1.pdf src2.pdf dst.pdf
will merge two pdfs files into one
$ xclock
$ oclock
will display clock
$ aspell -a
will correct the spelling from command line
$ screen -S rpyc
will create an new session with name 'rpyc'
use 'ctrl+a d' to detach from the current session
$ screen -ls
will lists all the sessions currently running
$ screen -R rpyc
will reattach to the existing screen
$ cut -c10-15 file
to print 10th-15th character of all lines in a file.
$ cut -d"/" -f2 file
takes every line and cuts the whole line into pieces saparated by '/',
and prints the second piece of the line.
$ echo "aaaaaaaa" | sed -e "s/a/f/4" -e "s/a/e/6g"
prints 'aaafaeee' replaces the 4th occurence of 'a' with 'f' and 6th to end of occurences
of 'a' with 'e'
$ sed -n '21,26p' file
prints the lines from 21-26 from the file
$ sed -e "s|$source_dir|$dist_dir|2"
replaces the occurence of variable $source_dir with $dist_dir where the contents of variables is a
addresses, like '/local/z/source/'.
note: in the place of '|', it will also support any character like '%','@','^','&', etc,.
$ sed -e "/^str0/ s/str1/str2/g"
replaces the 'str1' to 'str2' only in the lines which starts with 'str0'
$ who am i | cut -d' ' -f1
prints the name of the user who is presently loged in.
$ find -empty
lists all the empty folders in the current dir
$ find ./ -name "*" -print | xargs grep "string"
searches string in all the files in the present directory and prints the file name and
line number, where it finds that string.
$ find ./ -name "*" -print | xargs grep "string" | xargs echo
add echo at the end to saperate errors and wanted data (which comes at the last)
$ grep -nriH "string" dir/*
searches "string" in all the files in the directory "dir" recursively and prints the filename and
line no. with that string
$ find -name *.c
finds all .c files in present dir without recursuvely.
$ find -name "*.c"
finds all ./ files in present dir recursevely
$ find ~ -iname "*blast*"
same as above, but case insensitive
$ find ~ -type f -mtime -2
finds all files you have modified in the last two days in /root dir recursevely
$ find . -cmin -120
lists all the file which have modified before 120 minutes ago
$ find /tmp -name "core.txt" -type f -print0 | xargs -0 /bin/rm -f
Find files named 'core.txt' in or below the directory /tmp and delete them, processing filenames in
such a way that file or directory names containing single or double quotes, spaces or newlines are
correctly handled. The -name test comes before the -type test in order to avoid having to call
stat(2) on every file.
$ find ./ -name "*Wedding*" -exec mv {} ../dir/ \;
find files named 'Wedding' and executes 'mv' command by passing founded files as an arguments in place
of '{}'. the characters '\;' are must to terminate the '-exec' option. all the special characters
and spaces are handled by this command.
$ find -name "*.mp3" -ls
prints the files located as in the format of 'ls -sidl' format.
$ find -name "*.mp3" -exec head -132c {} \; -exec echo -e "\n-------" \;
$ find -name "*.mp3" -exec tail -128c {} \; -exec echo -e "\n-------" \;
used to print the mp3 file headers and footers....
$ rm -rvf $(find ./ -name "*.pdf")
Find all "*.pdf" files in a directory recursuvely and removes them.
$ mv $(find ./ -name "*.pdf") ../all_pdfs/
Find all "*.pdf" files in persent directory recursuvely and removes them to ../all_pdfs/ directory.
$ for i in *.txt; do mv $i ${i/name.new.txt}; done
renames file name.old to name.new
$ while [ 1 ] ; do echo -n "remove file: "; read filename; rm -f `echo $filename | sed "s/monkeylog.txt/\*/g"`; done
removes every file given in stdin interactively by replacing strings in filenames.
$ find -name "*.html" | while read file; do echo "$file: "; sed '/workspace/ d' $file > t; mv t $file; done
deletes lines which contains 'workspace' string in every *html file
$ cat filename.txt | tr ' ' '_'
prints the content of the file "filename" with all 'spaces' replaced by 'underscrores'
$ cat status | grep deviceaddr | awk -F= '{printf $2}'
prints the string after the '=' from line containing 'deviceaddr'.
$ cat status | grep port | awk '{print $5}' | awk -F= '{print $2}'
$ cat connected.txt | grep port | awk '{print $5}' | awk -Fport= '{print $2}'
cuts the string into two as reference to 'port=' and prints the right side string.
$ cat status | grep deviceaddr | awk -F= '{printf $2}' | awk -F= '{s=$2;printf("%d",s)}'
cuts the second string as reference to '=' character and prints the right side part of '=' character.
$ paste file1 file2 | awk -F "\t" '{print $1 "--->" $2}'
cuts the string as reference to tab character and prints first and second file contents with
pointing-to symbols in the middle.
$ awk '/sleep/ { print $1 }' filename
finds 'sleep' strings in a file and prints the first word of those lines.
$ awk 'length($0) > 80' test_directory/mmgsdilib/mmgsdilib_test.c
prints the lines which are more than 80 characters.
$ find -name "*.mp3" -ls | awk '{if ($2>1000) print $11; else print "ok"}'
prints the names of mp3 files which are less than 1MB in size otherwise just prints ok.
$ find -type f | awk -F. '{print $NF}' | sort | uniq -c
prints the count of the files existed with reference to its extensions
$ ls -ls * | awk '{total += $6} END{print total}'
finds and prints the sum of all the files sizes taken from the ls commands
$ ls | awk -F_ 'BEGIN {i=1} {printf("mv %s ~/local/Pictures/films-wallpapers/ntr/%s_%03d.jpg\n", $0, $1, i++)}' | sh
renames the files according to the number tags.
$ ls | awk -v i=1 -F_ '{printf("mv %s ~/local/Pictures/films-wallpapers/ntr/%s_%03d.jpg\n", $0, $1, i++)}' | sh
same thing as above but with -v option.
$ awk -v awkpackages_num=$package_num '{print $awkpackages_num}'
'-v' is used to pass shell variables to awk script. in the above example 'package_num'(shell variable)
is assigned to a 'awkpackages_num'awk variable.
$ ls | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $2}'
sorts the files according to its name lengths.
$ ifconfig | grep Bcast | awk '{split($2,a,":")}{print a[2]}'
will give the ip address of the machine
$ zenity --info --text "Hi"
displays a information windows with "Hi" as a text in that window.
'man zenity' for more details on GUI through zenity.
$ zenity --notification --window-icon 16x16image.png --text "Hi"
displays a given icon image in system tray list, with "Hi" as a information.
$ zenity --calendar --text "Hi"
displays a calendar with "Hi" as a information, and allows user to select any date.
returns the string equivalent of the user selected date to stdout.
in shell script, we can also store this returned string in a variable.
$ notify-send "Hi" "Time to Call"
displays a system notification icon
(for ((i=0;i<100;i+=4)) ; do echo $i ; sleep 1; done) | zenity --progress --auto-close
for having progress bar
$ gconftool-2 -R / | less
to get all the values
$ gconftool-2 --get /desktop/gnome/background/picture_filename
to print the current desktop background image path
$ gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$FILE_FULL_PATH"
changes the desktop background image in gnome environment.
$ gconftool-2 -t int -s /apps/gnome-power-manager/timeout/sleep_display_ac 60
to set the power management to sleep the display after 1min
$ gconftool-2 -R /desktop/gnome/background
prints all the keys present in '/desktop/gnome/background' key directory' recursevely.
$ gconf-editor
its an gui for adding and changing gnome keys.
$ gconftool-2 -t str -s /apps/metacity/global_keybindings/run_command_terminal "
to set the shortcut key for terminal lauching
$ gconftool-2 -t str -s /apps/metacity/global_keybindings/run_command_1 "
$ gconftool-2 -t str -s /apps/metacity/keybinding_commands/command_1 "/
to assign a custom keyboard shortcut for any command
if you link a python scripts for the keyboard shortcut use a shell script for debugging.
$ gconftool-2 --unset /apps/metacity/global_keybindings/run_command_1
$ gconftool-2 --unset /apps/metacity/keybinding_commands/command_1
to unset the gnome keys
$ gsettings list-recursively
to list all the schemas of the gnome-unity
$ gsettings range org.gnome.settings-daemon.plugins.power button-power
to list all the valid values for 'button-power' key
$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 3600
to set machine to sleep after 1 hour on ac power
$ gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']"
$ dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/name "'terminal'"
$ dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/command "'gnome-terminal --maximum'"
$ dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/binding "'
sets an keyboard shortcut '
$ dconf list /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/
for listing the dconf database of gnome-shell settings
$ gsettings get org.gnome.system.proxy ignore-hosts
$ gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '*.local', '100.64.147.206']"
will get no_proxy list and add new ip addresses to it
$ xrandr --listmonitors
will list the monitors currently configured
$ xrandr -s 0
will reset the current display's resolution
$ xrandr --auto
will attempt to enable all attached outputs
$ xrandr --newmode "800x480R" 28.25 800 848 880 960 480 483 493 499 +hsync -vsync
$ xrandr --addmode VGA1 "800x480R"
$ xrandr --output VGA1 --mode "800x480R" --left-of LVDS1
http://ubuntuhandbook.org/index.php/2017/04/custom-screen-resolution-ubuntu-desktop/
will create, add new monitor to the xprofile and switch on the monitor
this also can be added to ~/.xprofile file for persistantance
$ xrandr --output VGA --mode 1280x1024 --rate 60
changes the screen resolution to 1280x1024 with 60 screen refresh rate
$ xrandr --output HDMI1 --mode 1366x768 --rate 60 --right-of LVDS1
will switch on the panasonic hdmi display
$ xrandr --output LVDS1 --off
will switch off the inbuilt display
$ pactl list
will list all the sources, sinks and devices with their profiles
$ pactl set-card-profile
$ pactl set-card-profile alsa_output.pci-0000_00_1b.0 output:hdmi-stereo+input:analog-stereo
$ pactl set-card-profile alsa_output.pci-0000_00_1b.0 output:analog-stereo+input:analog-stereo
$ pactl set-card-profile alsa_card.pci-0000_00_1b.0 output:analog-stereo
$ pactl set-card-profile alsa_card.pci-0000_05_07.0 output:analog-surround-51
will set card to any one of the profiles it supports
use 'mplayer --ao=pulse::
$ pactl set-default-sink
$ pactl set-default-sink alsa_output.pci-0000_05_07.0.analog-surround-51
$ pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
will set default output audio to card with profile selected with previous command
$ pactl set-sink-volume
will set output volume to audio output to double
$ aplay --list-devices
will print the all the audio cards and devices supported
use 'mplayer -ao alsa:device=hw=
$ mail -s "mail_subject" "user@domain.com, user2@domain2.com" < mail_body.txt
sends mails through command line without user interaction.
$ wget -r -np -p -k "http://website.com/dir/link.to.any.htmlpage.html"
downloads the htmlpage and all the links associated with it recursively and makes html links, same
like as on the server.
$ wget -r -l1 -H -t1 -nd -N -np -erobots=off -A.mp3 -i websites.txt
reads the linking sites from the text file 'websites.txt' and downloads all *.mp3 files recursely.
$ wget --convert-links --html-extension http://www.intmath.com/Numbers/1_Integers.php
will download and convert php file to html file.
$ axel -n 10 http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.39.gz
will download faster with multi threads
$ date +"(%k*3600)+(%M*60)+%S" | bc
prints the present time in no.of sec from the night 12:00am.
$ sudo timedatectl set-timezone Asia/Kolkata
$ sudo dpkg-reconfigure tzdata
to correct the timezone
$ date -s "2012-05-12 22:24:00"
to set the time
$ sed "s|.*|'&'|g" | tr '\n' ' ' ; echo
to convert the line by line text from stdin to one line string with single codes separators.
$ find . -maxdepth 1 | xargs -I currentDir -t touch currentDir/.git/git-daemon-export-ok
use to create files in dynamic file system like git
$ curl -s -d 'htno=08m31a1230&ecode=1012' http://jntu.ac.in/results/results.php
will construct a html form of values given to '-d' option and sends to the remote php script.
'-s' is to run it in silent mode.
$ lsof | grep deleted_file
used to undelete the files
if the above command gives the output as
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
npviewer 28236 user 11u REG 8,5 9542278 302098 /tmp/FlashXXD1OaWH (deleted)
then use this command to restore the file
$ cp /proc/28236/fd/11 ~/restored_filename
$ tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock |GREP_COLOR="1;32" grep --color "[^ ]"
terminal matrix screen saver
$ yes "$(seq 232 255;seq 254 -1 233)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
print gray pattern in terminal
$ ecryptfs-setup-private
creates a ~/Private directory to contain encrypted information
$ ecryptfs-mount-private
will mount a users ~/private directory.
$ ecryptfs-umount-private
will unmount a users ~/private directory.
$ dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
$ dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
will list the dbus services in system and session busses respectively
$ gdbus introspect --system --dest org.freedesktop.UPower --object-path /org/freedesktop/UPower
will list all the properties, methods and signals assiociated with the service object
bash completion also works for service names and object names
$ dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.Suspend" boolean:true
will suspends the machine
$ obxprop | grep '^_OB'
will display window properties to fill '.config/openbox/lubuntu-rc.xml' in lubuntu
$ openbox --reconfigure
to update the configuration as per the changes in '.config/openbox/lubuntu-rc.xml' file
$ depmod -a
copy custom modules to /lib/modules/`uname -r`/kernel and run this command to generate modules.dep and map files
$ sudo mkfs.vfat -F32 -I /dev/sdc1 -n DriveName
$ sudo mkfs.vfat -F32 -I /dev/mmcblk0p1 -n DriveName
used to format the pendrive with vfat filesystem
the panasonic tv can support fat16 filesystems formated from window machines only
$ sudo mkfs.ntfs -F -Q -L DriveName /dev/sdc1
$ sudo mkfs.ext4 /dev/sdb1 -L DriveName
used to format the pendrive with ext4 filesystem.
$ sudo mkfs.vfat -F32 -I /dev/sdb1 -n DvdDrive
$ sudo mkfs.ext4 /dev/sdb2 -L BackUpDrive
for formatting 1 tb wd hdd drive
$ sudo mkdosfs -F32 -v /dev/sdb1 -n DriveName
used to format the harddisk with fat32 filesystem.
$ sudo fdisk /dev/sdb
used to make partitions on externel harddisk. after this u will enter into fdisk interaction mode.
m: for all supported options.
p: to print the partition table presently on the disk.
n: to add a new partition on the disk.
p: for primary partion.
1: for making it first partion.
a: to make boot partition.
1: to make first partition as a boot partition.
p: and check whether a '*' symbol lies on the boot column of the new partion.
w: to write this new partition table on the disk.
q: to quit from the fdisk without saving the partition table.
$ ifconfig
prints the all networks informations of the system
$ route add default gw 10.130.98.1
to set the default gateway as 10.130.98.1
$ sudo nethogs
shows the current network traffic as the processes
$ gksudo system-config-printer
open the printer settings gui interface with root permissions
$ ifconfig eht0 down
$ ifconfig eht0 192.168.128.118 up
for changing ipaddress of the system to *118.
$ sudo ifconfig eth0 down # on both machines
$ sudo ifconfig eth0 up -pointopoint 192.168.1.2 dstaddr 192.168.1.1 # on machine-1
$ sudo ifconfig eth0 up -pointopoint 192.168.1.1 dstaddr 192.168.1.2 # on machine-2
will create an point-point communication between two machines, when connected with
network cross cable
$ diff -b -i file1 file2
will print the unmatched lines of both files with '<' and '>' symbols
'<' extra line contained in file1.
'>' extra line contained in file2.
$ diff -qr distination/ source/ | sort
will print all the list of new and modified files in both the directories.
$ diff -Naur orginalDir changedDir > diffFile.patch
it will compare two directories and writes the differences in the diffFile.patch file.
$ patch -Np0 -i diffFile.patch (or) $ patch -p0 < diffFile.patch
it will create a "orginalDir" directory and places all the files in the files as in the orinal dir.
$ patch -p1 --dry-run < name.patch
checks whether the patch will apply safely or not.
$ patch -g1 -p1 < ~/tst50595
will automatically checkout the file from clearcase/perforce and apply the patch
$ sdiff -o outFile oldFile newFile
will interactively merges the two file and place the resulted output in outFile
interactive commands:
e: discard both versions, invokes a text editor, then copy the resulting file to the output
eb: concatenate the two versions, edit the result, then copy the edited result to the output
ed: like ‘eb’, except precede each version with a header of file and lines no
el: e1: edit a copy of the left version, then copy the result to the output
er: e2: edit a copy of the right version, then copy the result to the output
l: 1: copy the left version to the output
q: quit
r: 2: copy the right version to the output
s: silently copy common lines
v: verbosely copy common lines. this is the default
$ make --debug=a
gives all the information about the make process.
$ ssh root@192.168.128.221 "while [ 1 ]; do echo '1'; done > /dev/audio"
to find out the physical place of pc by having ip address. this assumes the
system with audio speakers and enough volume to search out.
$ dd if=/dev/zero of=folderFile bs=1M count=128 #(makes a 128M of file containing all zeros)
$ mke2fs folderFile #(formats with ext3 file system)
$ sudo mount -o loop -t auto folderFile restricted_folder
for creating a folder of limited size
$ mount -o loop -t iso9660 ./image.iso ./image/
used to mount the ios-image to a folder.
$ function m() { ls $1 $2; read; mp3info -x $1/*.mp3 $2/*.mp3 | less; }
used to compare two music folders
$ ssh -L [localPort]:machineB:22 userA@machineA
$ ssh -X -p [localPort] userB@localhost
to do X11 port forwarding of machineB to localhost via machineA
$ VBoxHeadless --startvm dvatvm --vrde on &
will start vm in background with vnc server on 3389 port
$ rdesktop-vrdp localhost:3389
will open vnc desktop openned with virtualbox
$ remote_time=`ssh user@machine1 date` && date -s '$remote_time'
will sync the current machine's time to remote machine
$ x11vnc
packages: x11vnc
vnc server to allow remote access to an existing x session
if any auth errors occurs, $ sudo cp /var/run/lightdm/root/:0 ~/.Xauthority
$ tightvncserver -geometry 1280x960 -depth 16 :1
$ packages: tightvncserver lxde-common
starts tightvncserver in new x session
if screen is gray, edit ~/.vnc/xstartup
- /etc/X11/Xsession
+ /usr/bin/startlxde &
$ tightvncpasswd
set or edit server password
in remmina, use as following
server :
user : tightvncserver process user
password : same as set by tightvncpasswd
$ remmina
packages: remmina remmina-plugin-vnc
remote desktop and vnc client for gnome desktop environment
$ udevadm monitor --property
monitor dynamic hardware changes
programing commands
$ ctags -R *
it creates one file having tags of every functions in every file.
opening a file with vim from present directory, place cursor on the string and press "ctrl + }".
it will show the place of defination of the function which is there in other file.
to come back to the working file press "ctrl + t"
$ ctags --language-force=java -R
to create java language tags
$ export LIBC_FATAL_STDERR_=1
export this variable to enable the libc errors to stderr
$ gcc -E program.c
prints the program text after pre-processor stage
$ gcc -lpthread program.c
to compile the program which has pthread implementation
$ gcc -x c file.dat
will compile file.dat file asuming as a '.c' file
$ gcc -static file.c
to generate a stand alone .out file with including required shared libs
$ gcc -I ./otherIncludeDir file.c
will add 'otherIncludeDir' also in the include dir list
$ strace -o trace_output
prints the trace output of the 'cmd' executed into a file 'trace_output'
$ strace -p
prints the trace output of the 'pid'
$ dstat
gives cpu, network and i/o stats of the system
$ iotop
simple top-like i/o monitor
$ perl -cw script.pl
will checks all the syntax errors
$ pydoc
man page for python libraries
$ python3 -m compileall p.py -b
will compile p.py as p.pyc binary
$ python -m trace -t p.py | less
$ python -m trace -t p.py | grep -e "^common.py" -e "^p.py" | less
display lines as they are executed. see http://docs.python.org/library/trace.html
for more options on trace.
$ python -m trace -c p.py
produce a set of annotated listing files [*.cover] upon program completion that shows how many
times each statement was executed.
$ python -m cProfile reminder.py "args"
profiles the script reminder.py
$ pycallgraph p.py
creates a call graph image by executing p.py script
$ alpp/construct_call_graph.py -i inputScriptFile.py
will display a function call graphs for a given script
$ alpp/construct_call_graph.py -i inputScriptFile.py > t.dot
$ vim t.dot
$ cat t.dot | dot -Tpng > t.png ; eog t.png
manually edit t.dot to delete some function's link lines
creates a call graph image for that .dot file.
$ javac file.java
compiles file.java file and creates a
$ java
runs the java class file and produces the output
$ javaws viewer.jnlp
will launch remote session which uses jnlp files
$ valgrind
finds the heap memory leaks in the program.
$ objdump -h lynx_sf.elf
to get information of different sections and their offsets in elf file
$ readelf -Ws yourLib.so
$ nm -g yourLib.so
to extract symbol information from .so or .elf file
$ readelf -wi lynx_sf.elf
$ objdump --dwarf=info lynx_sf.elf
to extract full information from .so or .elf file
$ pip install
$ pip --no-index --find-links='pathToLocalPipModules' install
to download python modules locally and install it offline
gdb commands
> r
run program
> r small
run program, and give it "small" as an argument.
> r < infile
run program, redirect input from file infile.
> b main
set a breakpoint in function main().
> b 36
break at line 36 of current source file.
> i b
info breakpoints. Lists all breakpoints now set up.
> d
delete all breakpoints (d 1 for just #1).
> n
execute next line of code.
> s
like next, but steps inside function calls.
> c
continue, Run from this point until breakpoint or program exit.
> p foo
print variable foo
> p/x foo
print foo in hex (/o = octal, /d = decimal)
> p *array@len
print the content of the array till the len
> display
print the variable automatically for every time of
> undisplay
to undisplay the value coresponding to displayCount
> i lo
info locals: values of all local vars, current function
> i var
info variables: values of global/static vars
> i s
info stack: calls made to get to this execution point.
> x 0x20034
examine memory address 0x20034
> x/s 0x20034
examine memory, addr 0x20034, as a string (also x/f)
> l
list source code (list 18 = code near line 18, list main, etc.)
> i fun
list of all functions in the program.
> h
top-level help, lists topics
> h b
help on break command
> h breakp
help on topic of breakpoints
> where
to view the stack
> ctrl+xa
to view the source file while debugging
> q
quit gdb
> set follow-fork-mode
set the debugger response to a program call of fork or vfork
> show follow-fork-mode
display the current debugger response to a fork or vfork call
cd-burning commands
$ wodim --devices
will give the connected devices and their dev node paths
$ growisofs -dry-run -V "volume_name" -speed=8 -iso-level 4 -joliet-long -Z /dev/dvd -r -R -J -l -L /some/files
simulates the dvd burning... without actually writing into the dvd.
$ growisofs -V "volume_name" -speed=8 -iso-level 4 -joliet-long -Z /dev/dvd -r -R -J -l -L /some/files
writes the empty dvd with /some/files folder using 8x burning speed.
growisofs uses 'genisoimage' internally. see 'man genisoimage' for more info.
$ growisofs -V "volume_name" -speed=8 -iso-level 4 -joliet-long -M /dev/dvd -r -R -J -l -L /some/morefiles
writes some more data on the media as a multi-session dvd continuation.
will overwrite the dir which is already written. this can also be used when
error occurs during disk write failure
$ mkisofs -J -R -o -iso-level 4 file.iso /some/files
$ mkisofs -J -R -o file.iso /some/files
$ eject
$ echo "press enter after putting blank dvd/cd:"; read
$ growisofs -dvd-compat -Z /dev/dvd=file.iso
creates an .iso image file from the /some/files dir.
takes the .iso image and burns on to the dvd with multisession option
$ readom dev=/dev/sr0 -nocorr -noerror -f=dvd.iso
$ sudo cdrecord dev=/dev/sr0 -v --eject dvd.iso
these two commands combination will copy a disk to the another disk
$ mkisofs -J -r -V Session2 -C `cdrecord dev=0,0 -msinfo` -o output.iso dirs/...
for creating iso with new file list (TOC)
$ mkisofs -J -r -V Session2 -C `cdrecord dev=0,0 -msinfo` -M 0,0 -o output.iso /path/to/back/up
for creating iso with append file list (TOC)
$ cdrecord dev=0,0 -v -eject speed=8 fs=16m -multi your_iso_file.iso
for burning multi-session cd burning
$ mkisofs -o ../centos.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "CentOS" .
to create bootable disk
$ usb-creator-gtk --not_persistent --safe --iso
gui to create bootable Ubuntu USB flash drive.
make only one partition in usb drive and format it with fat16/32 filesystem.
$ sudo umount /dev/sdd1 && sudo dd of=/dev/sdd bs=1M if=/path/to/file.iso
this will umount and create bootable usb pen drive
audio commands
$ alsamixer -c0
a command line tool for controlling system volumes.
$ speaker-test -D plug:front -c 2 -t sine -l 0
a command line tool to test the speakers.
$ speaker-test -c 6 -t wav -D surround51
a command line tool to test the surround 5.1 speakers
$ arecord --quiet --file-type wav --rate=44000 > test.wav
to record a audio to a file
$ mplayer -playlist ~/alp_programs/others/internetRadio.m3u
plays a internet radio of the link mentioned in the m3u file
$ mplayer cdda://2 -cdrom-device /dev/cdrom -cache 5000
plays music audio cdrom
$ mplayer -af volume=10.1:0 video.avi
will amplify the sound by 10.1dB and hard-clip if the sound level is too high.
$ mplayer --af=surround=1000,sub=150:5,center=4 --channels=6 file.mp3
will convert 2 channel stereo audio to 5.1 channel output, if your audio card supports 5.1 output
channels mapping (fl, fr, rl, rr, c, sw) = (0, 1, 2, 3, 4, 5)
$ mplayer --af=6:1:0:1.2:0:0.4:0.5:0:1:0:1.2:0.4:0.5
will map 2 channels into 6 channels in the form of
order will be fl,fr,rl,rr,c,lfe
$ mplayer --af=delay=15:15:30:30:0:30
ads delays in channels
$ mplayer --af=channels=6:2:0:2 file.mp3
will send sound to front left and rear left speakers only
$ mplayer mms://url -dumpstream -dumpfile foo.wmv
to record the radio streams audio
$ ssh user@10.130.100.177 'cat /path/to/file.mp3' | mplayer -
to play songs from the remote file through ssh
$ wget ftp://micorsops.com/something.avi -O - | mplayer -cache 8192 -
to play songs from the remote file through wget
$ lame --mp3input -b 128
used to convert the bitrate of the file.mp3 to 128.
size of the mp3 file will only depends on the bitrate but not on the sampling rate
or the number of channels.
$ lame --scale 0.5 i.mp3 o.mp3
decreases the volume level of the i.mp3 file
$ mp3info -p "%F: %a %l\n" file.mp3
prints the filepath, artist name and album name of the mp3 file.
$ id3v2 -l file.mp3
prints the all the tags presents in the file.mp3
$ id3v2 -D file.mp3
deletes all the tags in the file.
$ gst-launch audiotestsrc ! alsasink
plays an sine wave
$ gst-launch filesrc location=dts.wav ! decodebin ! audioconvert ! alsasink
plays audio file using gstreamer
$ gst-inspect
list all available gstreamer elements
$ gst-inspect filesrc
list full details about the selected gstreamer element
video commands
$ x11perf -range copywinpix10,comppixwin500 -time 1 -repeat 1
a command line tool to test video driver
$ mplayer vcd://1 -cdrom-device /dev/cdrom
$ mplayer vcd://2 -cdrom-device /dev/cdrom
used to play the vedio cd. track 1 or track 2 , etc..
$ mplayer -vo caca file.mp4
to render video on terminal with ascii equvalents of video content
$ mplayer -vo fbdev2 -fs -zoom -xy 1280 f.mp4
to render video to frame buffer and zoom it to screen width of 1280
$ vcdxrip --track 1
$ vcdxrip --track 2
used to rip the video files from the vcd disk to pwd. track 1 or track 2, etc,.
$ cdrdao read-cd --device /dev/cdrom --paranoia-mode 2 --read-raw file.toc
used to read raw data on the cd and create corresponding "file.toc" and "data.bin" file.
$ cdrdao write --device /dev/cdrom --speed 16 file.toc
will writes the "file.toc" cd image into the empty cd.
$ vlc v4l2:///dev/video0
$ vlc v4l2:// :v4l-vdev="/dev/video0" :v4l-adev="/dev/audio2" :v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=-1 :v4l-stereo :v4l-width=640 :v4l-height=480 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :v4l-decimation=1 :v4l-quality=100
$ mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0
used to view the image from webcam
$ mplayer --vf=stereo3d=sbsl:aybc,scale world_s_best_sbs_3d_pop_out_effects_ever.webm
used to view 3d video with blue and cyan shift
$ quvi 'http://www.youtube.com/watch?v=eCpkq_AeX50' --exec 'mplayer -cache 8192 %u'
will play stream from youtube into mplayer
$ mplayer -identify -frames 0 file.mp4
$ ffmpeg -i file.mp4
$ ffprobe file.mp4
Gets infos from a video file
$ idvid -fast file.avi
identifies video file and reports its compliance with video disc standards such as VCD, SVCD, and DVD.
other tools from 'tovid': idvid,makedvd,makemenu,makeslides,makevcd,makexml,postproc,tovid,todisc
$ cclive 'http://www.youtube.com/watch?v=eCpkq_AeX50'
download the video from youtube site
$ ffmpeg -re -i narayan_narayan.mp3 -f mpegts -muxdelay 0.1 udp://remoteIp:2222
$ mplayer -udp-slave -cache 64 udp://remoteIp:2222
internet radio, the ffmpeg acts like a server which will stream mp3 into udp of remote machine
and mplayer running on client will listen the stream
ffmpeg video encoding commands
$ ffmpeg -i i.mkv -c:v copy -af "volume=2" -threads 0 o.mkv
to amplify the audio volume by 200% in the video file
$ ffmpeg -f image2 -i image%d.jpg video.mpg
Turn X images to a video sequence
$ ffmpeg -i video.mpg image%d.jpg
Turn a video to X images
$ ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
Extracting sound from a video, and save it as Mp3
$ ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3
Convert a wav file to Mp3
$ ffmpeg -i video_origine.avi video_finale.mpg
Convert .avi video to .mpg
$ ffmpeg -i video_origine.mpg video_finale.avi
Convert .mpg to .avi
$ ffmpeg -i video_origine.avi gif_anime.gif
onvert .avi to animated gif(uncompressed)
$ ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Mix a video with a sound file
$ ffmpeg -threads 0 -i in.3gp -c:v mpeg4 -vsync 2 -r 24 -b 570k -f mp4 -c:a libfaac -async 1 -ab 128 -ac 2 -ar 44100 out.mp4
converts any video to .mp4 format
$ ffmpeg -threads 0 -i king.mkv -c:v mpeg4 -vsync 2 -r 20 -b 700k -minrate 700k -maxrate 700k -bufsize 1000k -f mp4 -c:a libfaac -async 1 -ab 128 -ac 2 -ar 44100 king1.mp4
converts to .mp4 with most constant and accurate video bitrate
$ ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv
Convert .avi to .flv
$ ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv
$ ffmpeg -i video_origine.avi -target pal-dv video_finale.dv
Convert .avi to dv
$ ffmpeg -y -i in.mp4 -r 20 -s 352x288 -b 400k -c:a libfaac -ac 2 -ar 8000 -ab 24k out.3gp
used to convert from .mp4 to .3gp(mobile) format
$ ffmpeg -ss 300 -t 10 -threads 0 -i 1.mkv -c:v mpeg4 -vsync 2 -r 24 -b 750k -minrate 750k -maxrate 750k -bufsize 750k -f mp4 -c:a libmp3lame -async 1 -ab 64k -ac 2 -ar 22050 1.mp4
used to convert any video to .mp4 format
$ ffmpeg -i in.avi -t 10 -r 15 -s 320x136 -b 570k -c:a libfaac -ac 2 -ar 8000 -ab 24k out.mp4
used to convert any video to mobile compactable video of mp4 type.
where resolution is calculated from the input file keeping aspect ratio as constanst.
here in this example the resolution of input file is of 608x256. so the resolution that
can be used will be 320xWIDTH where WIDTH=(320/(608/256)).
$ ffmpeg -ss 3600 -t 10 -i in.avi out.avi
to get only 10 seconds of video slice after the 3600 seconds of input video
$ ffmpeg -i in.avi -c:v h263 -s 352x148 -b 300k -r 15 -padtop 70 -padbottom 70 -padcolor 000000 -c:a libfaac -ar 8000 -ab 12.2k -ac 2 -f 3gp out.3gp
used to convert any video to mobile compactable video. The resolution should be
calculated from the aspect ratio of input file and making adjustments with -pad* options
$ ffmpeg -i input.avi -f avi -c:v wmv2 -c:a mp2 -r 80 -s 1920x1080 out.wmv
to convert video from .avi format to .avi format .wmv
$ ffmpeg -i input.mpeg -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 out.flv
to convert video from .mpeg format to .avi format .flv
$ ffmpeg -i i.avi -f mp4 -c:v libx264 -crf 28 -threads 0 -flags +loop -cmp +chroma -deblockalpha -1 -deblockbeta -1 -refs 3 -bf 3 -coder 1 -me_method hex -me_range 18 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 320 -keyint_min 25 -level 41 -qmin 10 -qmax 51 -qcomp 0.7 -trellis 1 -sc_threshold 40 -i_qfactor 0.71 -flags2 +mixed_refs+dct8x8+wpred+bpyramid -c:a libfaac -ab 80kb -ar 48000 -ac 2 1.h264
$ ffmpeg -i i.avi -pass 2 -c:v libx264 -b 700 -g 300 -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -c:a libfaac -ab 64k o.mp4
to convert any video to h264 video format
$ ffmpeg -y -i i.mp4 -pass 1 -c:v libx264 -b 750k -g 300 -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -c:a libfaac -ab 128k o.mp4
to convert any video to h264 video format
$ ffmpeg -t 5435 -i file.avi -c:a copy -c:v copy part1.avi
$ ffmpeg -ss 5435 -i file.avi -c:a copy -c:v copy part2.avi
$ ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
$ ffmpeg -f alsa -ac 2 -i hw:0,0 -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
$ ffmpeg -formats
Show available formats, codecs, protocols, ...
$ ffmpeg -threads 0 -i king.mkv -codec copy king1.mp4
to convert mkv video to .mp4 with same quality as input
$ ffmpeg -threads 0 -i i.webm -c:v mpeg4 -vsync 2 -r 24 -b 1000k -f mp4 -c:a libvo_aacenc -async 1 -ab 64k -ac 2 -ar 22050 o.mp4
$ ffmpeg -threads 0 -i i.mkv -c:v mpeg4 -vsync 2 -r 24 -b:v 1800k -f mp4 -c:a libvo_aacenc -async 1 -b:a 64k -ac 2 -ar 22050 -vf 'pad=iw:iw*9/16:(ow-iw)/2:(oh-ih)/2' o.mp4
convert any video to panasonic tv compatable, for landscape video
$ ffmpeg -threads 0 -i i.mkv -c:v mpeg4 -vsync 2 -r 24 -b:v 1800k -f mp4 -c:a libvo_aacenc -async 1 -b:a 64k -ac 2 -ar 22050 -vf 'pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2' o.mp4
convert any video to panasonic tv compatable, for portrait video
$ ffmpeg -threads 0 -i i.mkv -c:v libx264 -vsync 2 -r 24 -b:v 750k -c:a libmp3lame -af "dynaudnorm" -async 1 -ar 44100 -b:a 128k -ac 2 o.mkv
convert any video to projector compatable
$ ffmpeg -y -threads 0 -i i.mkv -b 1000k -vf 'scale=w=min(480\,iw):h=-1' -ab 128k -ar 22050 -ac 2 o.webm
convert any video to firefox phone compatable
$ ffmpeg -i i.mp4 -c:v libx264 -c:a copy o.mkv
convert any video to mkv format without loosing the quality
$ ffmpeg -i i.avi -c:v libx265 -preset medium -crf 28 -c:a libvo_aacenc -b:a 128k o.mkv
convert any video to hevc format without loosing the quality
$ ffmpeg -i i.mp4 -map 0:0 -map 0:2 -c:v copy -c:a copy o.mp4
to remove audio track 1 (0:0 is video, 0:1 is audio1, 0:2 is audio2; info from avprobe)
$ ffmpeg -i i.mpg -c:a libvorbis -aq 5 -ac 2 -qmax 25 -threads 2 m.webm
convert any video to webm format, -qmax can be from 10 (high quality) to 51 (low quality)
$ ffmpeg -i i.mp4 -vf "crop=iw:168:0:60" o.mp4
crops the video
$ ffmpeg -i concat:'1.avi|2.avi' -c copy o.avi
merge two videos mpeg1 or mpeg2 files into one
concat protocol: use with formats that support file level concatenation (MPEG-1, MPEG-2 PS, DV).
$ echo -e "file '/path/to/file1'\nfile '/path/to/file2'\nfile '/path/to/file3'" > filelist.txt
$ ffmpeg -f concat -i filelist.txt -c copy o.mkv
merge videos with mp4 or mkv formats into one
concat demuxer: use when you want to avoid a re-encode and your format does not support file level concatenation.
$ ffmpeg -i opening.mkv -i episode.webm -i ending.mkv -filter_complex '[0:0] [0:1] [1:0] [1:1] [2:0] [2:1] concat=n=3:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' output.mkv
merge videos with different codecs into one
concat filter: use if you need to re-encode such as when applying filters.
$ ffmpeg -i i.mp4 -f srt -i i.srt -c:v copy -c:a copy -scodec mov_text o.mp4
to add srt file to the video
$ ffmpeg -i i.mp4 -af "dynaudnorm" -c:v copy -c:a copy o.mp4
will normalize the audio level to peak without dissortion
mencoder video encoding commands
$ mencoder screencast.ogv -ofps 23.976 -ovc lavc -nosound -o screencast.avi
to convert video from .ogv format to .avi format
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:576,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 25 -o movie.mpg movie.avi
to convert any format video to dvd pal
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 30000/1001 -o movie.mpg movie.avi
to convert any format video to dvd ntsc
$ mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf -vf scale=720:576,harddup -ofps 25 -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:aspect=16/9 -o movie.mpg movie.avi
to convert PAL AVI Containing AC-3 Audio to DVD
$ mencoder -oac copy -ovc lavc -of mpeg -mpegopts format=dvd:tsaf:telecine -vf scale=720:480,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=15:vstrict=0:aspect=16/9 -ofps 24000/1001 -o movie.mpg movie.avi
to convert NTSC AVI Containing AC-3 Audio to DVD
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf scale=480:576,harddup -srate 44100 -af lavcresample=44100 -lavcopts vcodec=mpeg2video:mbd=2:keyint=15:vrc_buf_size=917:vrc_minrate=600:vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224:aspect=16/9 -ofps 25 -o movie.mpg movie.avi
to convert any format video to PAL SVCD
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf scale=480:480,harddup -srate 44100 -af lavcresample=44100 -lavcopts vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224:aspect=16/9 -ofps 30000/1001 -o movie.mpg movie.avi
to convert any format video to NTSC SVCD
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224:aspect=16/9 -ofps 25 -o movie.mpg movie.avi
to convert any format video to PAL VCD
$ mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf scale=352:240,harddup -srate 44100 -af lavcresample=44100 -lavcopts vcodec=mpeg1video:keyint=18:vrc_buf_size=327:vrc_minrate=1152:vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224:aspect=16/9 -ofps 30000/1001 -o movie.mpg movie.avi
to convert any format video to NTSC VCD
$ mencoder -forceidx -ovc copy -oac copy -o file.avi part1.avi part2.avi ...
to merge two identical format files into one file
$ mencoder -ss 100 -endpos 200 -forceidx -ovc copy -oac copy -o part2.avi fullfile.avi
to cut some partial part of the movie
$ mencoder -forceidx -ovc copy -oac copy -endpos 5435 -o part1.avi file.avi
$ mencoder -forceidx -ovc copy -oac copy -ss 5435 -o part2.avi file.avi
to split one file into two parts
$ mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -ovc lavc -o webcam.avi
$ mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0:forceaudio:adevice=/dev/dsp1 -ovc lavc -oac mp3lame -lameopts cbr:br=64:mode=3 -o webcam.avi
used to record the video from the webcam
$ mencoder -ovc copy -nosound i_robot.mkv -o v.mkv
to remove the audio track from the video file
$ mencoder -oac copy -novideo i_robot.mkv -o a.mp3
$ mencoder -oac copy -vc null -vo null i_robot.mkv -o a.mp3
to remove the video data from the file, means to get only audio from the video file
$ mencoder -ovc copy -audiofile leftAudio.m4a -audiofile rightAudio.m4a -oac copy i.mkv -o o.mkv
to add audio tracks to the video file
$ mencoder -delay 0.7 -oac copy -ovc copy video.avi -o output.avi
adds a delay of 0.7 seconds to the video data.
imaging commands
$ identify filename.jpg
displays the size of an image in pixels.
$ convert sourcefilename.jpg -thumbnail 128x128 newfilename.jpg
converts the jpg files of any size to limited size of 128x128 pixels(we can change the pixels value also)
$ convert 1.jpg 2.jpg 3.png +append m.jpg
will append all the input images horizontally
$ convert 1.jpg 2.jpg 3.png -append m.jpg
will append all the input images vertically
$ convert -rotate -90 1.jpg m.jpg
will rotate the image to 90 degress anti-clockwise
$ convert -rotate +90 1.jpg 2.jpg 3.jpg +append m.jpg
will rotate the images 90 degres clockwise and append all the images into m.jpg
$ convert textImage.gif textImage.pnm && gocr textImage.pnm
$ djpeg -pnm -gray textImage.jpg | gocr -
will recognises and prints the text in a image file
$ feh -A "mv -v %f /tmp"
will run mv command on image file when 0 key is pressed
bluetooth commands
$ sudo service bluetooth start
$ bluetoothctl
https://wiki.archlinux.org/index.php/Bluetooth
http://slist.lilotux.net/linux/bluetooth/
$ bluetoothctl
intractive command line tool
$ hcitool scan
scans the available devices in proximity
$ sdptool records F4:F5:24:AE:FB:20
$ bccmd
$ hciattach
$ gatttool
$ bluemoon
$ rctest
$ hex2hcd
$ obexctl
$ btmgmt
$ l2test
$ ciptool
$ rfcomm
$ l2ping
$ btmon
$ btattach
git commands
$ git init
initialises the git folder
$ vim .git/config (add these lines)
[user]
name = User Name
email = user@domain.com
$ git clone /local/git/location
$ git clone ssh://[user@]host.xz[:port]/path/to/repo.git
$ git clone git://host.xz[:port]/path/to/repo.git
$ git clone rsync://host.xz/path/to/repo.git
will clone the remote git into local
$ git add "file1" "file2" "folder1"
adds the files to the git index cache
$ git update-index
updates the cache with the files modified
$ git update-index --add
adds new file to index cache
$ git rev-list HEAD
shows all the commits reachable from HEAD
$ git rev-list HEAD^
shows all the commits reachable from one before HEAD
$ git rev-list HEAD~
shows all the commits reachable from one before HEAD
$ git rev-list HEAD~5
shows all the commits reachable from five before HEAD
$ git rev-list b1 ^master
$ git rev-list master..b1
shows all the commits reachable from b1 and not from master
$ git rev-list b1 ^b2 b3 ^master
shows all the commits reachable from b1,b3 and not from b2,master
$ git rev-list b1 b2 --not $(git merge-base --all b1 b2)
$ git rev-list b1...b2
shows all the unique commits of b1 and b2 leaving common commits
$ git diff
shows the diff of working tree to index
$ git diff --cached
shows the diff of index to HEAD
$ git diff HEAD
shows the diff of working tree to last commit
$ git diff --name-only mybranch ^master
shows list of files from mybranch and not from master branch
$ git diff-files
lists the modified files list and their blob object details between working tree and index
$ git apply --check p.patch
$ git apply --reject --whitespace=fix p.patch
to apply the patch generated by 'git diff'
$ git apply --reverse p.patch
to reverse the patch which has been applied earlier
$ git commit -m "comment_msg"
commits the changes from index but not from working tree
$ git commit -a -s
auto adds files modified and commit to the git using editor
$ git commit --amend
modifies the last committed message
$ git log --stat
gives full detail log history with files changed
$ git log -p file
gives full diff of the file in entire history
$ git status
gives the change file list of the git folder
$ git ls-files
lists all the files which are added to git
$ git ls-files --stage
lists all the files in index
$ git rm
removes the file from the git file list
$ git mv
moves the file
$ git reset HEAD
resets the branch to the latest commit-id
$ git reset --hard HEAD^
resets branch to the one before latest commit-id
$ git branch
gives the list of the git branches
$ git branch "newBranch"
creates a new branch in the git
$ git checkout
reverts back the changes in the file to commitID (or HEAD by default)
$ git checkout "newBranch"
checkouts to the new branch
$ git checkout -b "newBranch"
creates a new branch based on HEAD and switches to it
$ git branch -m "oldname" "newname"
renames the branch
$ git checkout "commitID"
checkouts the git folder to the selected commit id
$ git checkout -b "newBranch" "commitID"
creates a newbranch based on commitID and switches to it
$ git checkout "file" "commitID"
reverts back the changes in the file to commitID (or HEAD by default)
$ git reset HEAD "file"
revert the changes made in file
$ git reset --hard "commitID"
reset to the commit ID in a same branch
$ git fetch ssh://user@10.177.219.46/home/user/workspace/cc_saffire remoteB:localB
fetch remoteBranch to localBranch from remote node using ssh protocol
$ git push ssh://user@192.168.128.8:3984/home/scm/git/public/test-framework/autotest.git refs/heads/ths_unstable:refs/heads/ths_unstable
push the branch into remote server git (3984, is a port no. of the server)
$ git gc --aggressive --prune=now
packs the git objects, thus reduces the filecount and size of the git folder.
$ git archive --format zip -o ~/nodeTracker.zip HEAD
zips all the git indexed files
$ vim .gitignore # can place in main directory or at sub directories
pylog # ignores files with filename 'pylog'
f/*.c # ignores all '*.c' files in folder 'f'
/*.c # ignores "cat-file.c" but not "mozilla-sha1/sha1.c"
*.swp # ignores all the files ending with '.swp'
*.[oa] # ignores all the files ending with '.o' and '.a'
^a* # ignores all the files starting with 'a'
bin/ # ignores all the contents of folders 'bin'
* # read next line
!a # explicitily unignores file 'a' when '*' is used.
$ git status --ignored
will list the files that are ignored by the git
$ for f in `ls .git/objects/*/*`; do o=${f//\//}; echo -n "$f: $o "; git cat-file -t $o; done
lists the objects and their types in git terms
$ git cat-file -t
show the type of the selected gitObject; this can return values like commit, blob or tree
$ git cat-file blob
prints the content of blob(file) object
$ git cat-file commit
prints the content of commit object
$ git ls-tree
prints the content of tree object
$ git prune
removes all dangling git objects from the repository
$ git gc
$ git gc --aggressive
cleanup unnecessary files and optimize the local repository
$ git merge branch1 branch2
will merge the git branches
$ git merge --abort
will undo the merge conflits
$ git reset --merge
will undo the applied merge commits
$ git config --global core.filemode false
for ignoring file modes
$ git show-ref --tags
list all the tags along with commit ids to which they refered to
mobile commands
$ set the details of the phone in ~/.gnokiirc file as
[global]
port = /dev/ttyACM0
model = AT
connection = serial
$ gnokii --identify
to identify and get the full details of the phone connected
$ gnokii --getdatetime
to get the time of the mobile device
$ gnokii --getphonebook ME 1 end -r
to read the phonebook details from the location 1 to END in raw mode
$ gnokii --getphonebook MC 1 end -r
to get all the missed call entries
$ gnokii --showsmsfolderstatus
to show the msg folders and no.of mesgs contained in each folder
$ gnokii --getsms SR 0 end -f
to get the sms from 0 to END and write these all msgs in to file.
bash terminal shortcuts
ctrl + b
moves the cursor backward one character
ctrl + f
moves the cursor forward one character
alt + b
move the cursor to the beginning of the current or previous word
alt + f
move the cursor to the end of the next word
ctrl + a
move the cursor to the beginning of the current line
ctrl + e
move the cursor to the end of the current line
ctrl + t
swaps two characters before and after the cursor
alt + t
swaps two words before and after the cursor
ctrl + h
erase one character before the cursor
ctrl + d
erase one character under the cursor
ctrl + w
cuts the word before the cursor
alt + d
cuts the word after the cursor
ctrl + u
cuts the all characters left to the cursor
ctrl + k
cuts the all characters right to the cursor
ctrl + y
paste the characters cutted by the above shortcuts
ctrl + j
will runs the command, works just like 'enter'
ctrl + l
clears the screen of the terminal
ctrl + p
moves backward in the command history
ctrl + n
moves forward in the command history
ctrl + r
search the last command that contained the letters you're typing in reverse order
ctrl + s
search the last command that contained the letters you're typing in forward order
ctrl + c
kill the current process
ctrl + z
suspends the current process. then type 'bg' to make it background
and type the command 'fg' to get the process foreground
ctrl + d
log out from the current terminal when command string is present at the prompt
alt + .
repeats the last argument for the command last used
!$
repeats the last argument for the command last used
!!
repeats the line last entered at the shell
alt + ?
show current completion list
alt + *
insert all possible completions
alt + c
capitalize the first letter of the word
alt + l (or)
make complete word lowercase
alt + r
recall command
esc + u
capitalize the complete word
esc + l
make complete word lowercase
gnu commands src
$ curl http://git.savannah.gnu.org/r/
to list the gnu commands gits
$ wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.4.tar.gz
to download gnu commands src.
$ git clone git://git.savannah.gnu.org/r/
$ git clone http://git.savannah.gnu.org/r/
to download or git clone of gnu commands.
replace
imp packages: coreutils, gawk, sed, etc,.
shell scripts
$ shc -r -f daemon.sh
converts the shell scripts to binary codes. used to secure the
source code so that nobody can read the source code.
$ sudo cd /etc/init.d/
$ sudo cp ~/alp_programs/shell/startupScripts .
$ sudo chmod +x startupScripts
$ sudo update-rc.d startupScripts defaults 99 99
do the above steps and add the command to run the script
(like: /bin/sh /full/path/to/script.sh arguments... &)
in startupScripts to make a script to start at boot time.
Please don't forget to run all the scripts in background.
$ sudo update-rc.d -f startupScripts remove
for removing all the links from the run-levels
sql commands
$ mysql -u root "database" -p "password"
for login into the mysql with password and selected database
$ mysql -uroot -p "password" < sqlQuieries.sql
to run the set of sql Quieries from the file 'sqlQuieries.sql'
$ mysqldump
to dump the database data into a text file
$ mysqladmin -uroot -p create "database"
to create the empty data base
$ mysql -uroot -p "password" "database" < data.txt
retrive the data from text file to database
> show databases;
for listing the all the databases in the mysql
> use "database";
for selecting the database of name
> list tables;
for listing the all the tables in the mysql
> desc "table";
shows all the fields and their data types
> insert into "table" (machine_idx, hostname, machine_group, owner) values (23, '192.168.128.234', '192.168.128.234', NULL);
inserts the row into the 'table' table with values given
> select * from "table";
lists all the rows in the table of name "table"
> select name from "table";
lists all the rows of colunm 'name' in table "table"
> select * from "table" limit 10;
lists only first 10 rows of the table
> select * from "table" where name='dd_lgr01';
lists only one row where the colunm 'name' is equal to 'dd_lgr01'
> select * from "table" where name like 'dd_%';
lists all the rows where the colume 'name' is equal to 'dd_*' (wildcards substitution)
> select * from "table" where id between 10 and 100;
lists all the rows where the colume 'id' is between 10 to 100
> delete from "table" where name='dd_lgr01';
delete the one row where the colunm 'name' is equal to 'dd_lgr01'
> delete from "table" where name like 'dd_%';
delete all the rows where the colume 'name' is equal to 'dd_*' (wildcards substitution)
> drop database "database";
for droping the databases
perforce commands
$ p4 help
to get help
$ p4 sync -n
to know how many files are going to sync up use
$ p4 sync
for autual sync up
$ p4 sync //sw/apps/embedded/autosan/common/*
to sync one selected file or folder use
$ p4 filelog
to get the change lists logs of selected file
$ p4 changelists -l
to get the change lists of selected file
$ p4 describe
to get full details of selected changelist
$ p4 edit
to open a file for editing
$ p4 opened
to list all the files which are opened for editing
$ p4 diff
to get the diff of client file with depot file
$ p4 print
to get the file of previous revision
$ p4 dirs //sw/mobile/git/android/*
to display all the folders in depot dir
Regular expression
.
Matches any single character.
?
The preceding item is optional and will be matched, at most, once.
*
The preceding item will be matched zero or more times.
+
The preceding item will be matched one or more times.
{N}
The preceding item is matched exactly N times.
{N,}
The preceding item is matched N or more times.
{N,M}
The preceding item is matched at least N times, but not more than M times.
-
represents the range if it's not first or last in a list or the ending point of a range in a list.
^
Matches the empty string at the beginning of a line; also represents the characters not in the range of a list.
$
Matches the empty string at the end of a line.
\b
Matches the empty string at the edge of a word.
\B
Matches the empty string provided it's not at the edge of a word.
\<
Match the empty string at the beginning of word.
\>
Match the empty string at the end of word.
[ab]
Match any of the charaters in between of '[' ']'
[a-z]
Match any of the charaters between 'a' 'z'
|
Two regular expressions may be joined by the this infix operator
\
to override expression metacharacters like "\?", "\+", "\{", "\|", "\(", and "\)"
[[:alnum:]]
[[:alpha:]]
[[:ascii:]]
[[:blank:]]
[[:cntrl:]]
[[:digit:]]
[[:graph:]]
[[:lower:]]
Match all the the lowercase letters
[[:print:]]
[[:punct:]]
[[:space:]]
[[:upper:]]
Match all the the uppercase letters
[[:word:]]
[[:xdigit:]]
important file locations
/boot/grub/grub.cfg
this is the file to configure default operating system to select
/boot/config-2.6.38-8-generic
current kernel configs file
/usr/share/dict/words
contains all the words identified by the system
/var/cache/apt/archives
contains all the .debs files downloaded by the apt-get manager
/var/lib/dpkg/status
dpkg status file where all the installed package lists and their dependencies were listed
/etc/init/
if you put a myService.conf file in the above folder, it will become a upstart service and starts-up
default in selected runlevels. assuming your service is a daemon of continually running.
$ cat /etc/init/myService.conf
description "My service"
author "Some Dude
start on runlevel [234]
stop on runlevel [0156]
chdir /some/dir
exec /some/dir/script.py
respawn
$ sudo initctl reload-configuration
$ sudo start myService
$ sudo stop myService
/etc/xdg/autostart
~/.config/autostart
if you put a .desktop file in these folder it will become a global/user specific startup application
$ cat ~/.config/autostart/thunderbird.desktop
[Desktop Entry]
Type=Application
Exec=/usr/bin/thunderbird
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_IN]=thunderbird
Name=thunderbird
Comment[en_IN]=thunderbird
Comment=thunderbird
No comments:
Post a Comment