Tuesday, June 14, 2011

General shortcuts

# Login as a root:
    sudo su -
    sudo means 'super user do'.
# To start a root shell (i.e. a command window where you can run root commands), starting root's environment and login scripts, use:
    sudo -i     (equivalent to sudo su - , gives you roots environment configuration)
# Start a root shell, but keep the current shell's environment, use:
    sudo -s     (equivalent to sudo su)
# To execute more than one cmd use '&&' like
    $ make && make install
# To search for a pacakage
    $ sudo aptitude search
  or to list only the latest
    $ sudo aptitude show
# To install dependencies
    $ apt-get build-dep
# To empty the Trash
    $ rm -rf ~/.Trash/*
    $ sudo rm -rf ~/.local/share/Trash/files/*
# To find the process id's of given process and its related things
    $ pgrep
# Execute The Last Executed Command
    $ !!
# Execute The Last Command Starting With.. S
    $ !s
# Run a Command Repeatedly and Display the Output. Watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds. watch is very similar to tail.
    $ watch -d ls -l
    This will watch the current directory for any file changes and highlight the change when it occurs.
# Save Quickly in VI/VIM. If you’re in a hurry, you can save and quit the file you’re editing in vi by exiting insert mode, holding shift, and hitting z twice.
# Quickly Log Out of a Terminal

    $ CTRL+d
# Navigate to the Last Directory You Were In
    $ cd -
# Make Parent Directories the Smart Way
    $ mkdir -p /home/adam/make/all/of/these/directories/

    will create all sub directories as needed even if it is not.
# To Set custom time stamp of a file
    $ touch -c -t 0801010800 filename.c
    will show the time stamp as 2008-01-01 8:00. The format is (YYMMDDhhmm).
# To print the files content which names are all start with ho*

    $ ls -l |grep -v ho*
# To print all the hardware details
    $ lshw
   for html output
    $lshw -html > path/sys.html
# To list all the installed packages
    $ dpkg -l
    to list the installed paths
    $ dpkg -L
# To search a pattern in files
    $ find -R "pattern" *
# To disable power button action
    $ chmod 000 /etc/acpi/powerbtn.sh
# To display all the USB Devices connected
    $ lsusb

No comments:

Post a Comment