Never Ending Security

It starts all here

Command Line Interface Cheatsheet

CLI Magic: I Didn’t Know That !

Linux command line is really fascinating. You don’t believe me ?  Check out some of the commands below…

  • sudo!! : Forgot to run a command with sudo? You need not re-write the whole command, just type “sudo!!” and the last command will run with sudo.
  • Python -m SimpleHTTPServer : Creates a simple web page for the current working directory over port 8000.
  • mtr : A command which is a combination of ‘ping’ and ‘traceroute’ command.
  • Ctrl+x+e : This key combination fires up, an editor in the terminal, instantaneously.
  • nl : Outputs the content of text file with lines Numbered.
  • shuf : Randomly selects line/file/folder from a file/folder.
  • ss : Outputs Socket Statistics.
  • Last: Want to know history of last logged in users? This command comes to rescue here.
  • curl : Shows machine’s external IP Address.
  • tree : Prints files and folders in tree like fashion, recursively.
  • Pstree : Prints running processes with child processes, recursively.
  • <space> command : A space before a bash command, is not recorded in history.
  • stat : Shows the status information of a file as well as of a file system.
  • <alt>. And <esc>. : A tweak which put the last command argument at prompt, in the order of last entered command, appearing first.
  • Pv : outputs simulating text, similar to hollywood movies.
  • Mount | column -t : Lists mounted file system, in nice formatting with specification.
  • Ctrl + l: clear shell prompt, instantaneously.
  • curl -u gmail_id –silent “” | perl -ne ‘print “\t” if //; print “$2\n” if /(.*)/;’. This simple scripts, opens up, unread mail of an user, in the terminal itself.
  • screen : Detach and Reattach, long running process from a session.
  • file : Outputs information, regarding types of file.
  • id : Print User and Group Id.
  • ^foo^bar : Run last command with modification, without the need of rewriting the whole command again.
  • > file.txt : Flush the content of a text file, in a single go, from the command prompt.
  • at : Run a particular command, time based.
  • du -h –max-depth=1 Command : Outputs the size of all the files and folders within current folder, in human readable format.
  • expr : Solve simple mathematical calculations from the terminal.
  • look: Check for an English word, from the dictionary, in case of confusion, right from the shell.
  • yes : continues to print a sting, till interrupt instruction is given.
  • factor: Gives all the possible factors of a decimal number.
  • ping -i 60 -a IP_address : Pings the provided IP_address, and gives audible sound when host comes alive.
  • tac : Prints content of a file, in reverse order.
  • strace : A debugging tool.
  • disown -a && exit Command : Run a command in background, even after terminal session is closed.
  • getconf LONG_BIT Command : Output Machine Architecture, very clearly.
  • while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done & : The script outputs date and time on the top right corner of shell/ terminal.
  • convert : converts the output of a command in picture, automatically.
  • watch -t -n1 “date +%T|figlet” : Show animated digital clock at the prompt.
  • host and dig : DNS lookup utility.
  • dstat : Generates statistics regarding system resource.
  • bind -p : Shows all the shortcuts available in Bash.
  • Touch /forcefsck : Force file-system check on next boot.
  • lsb_release : Prints distribution specification information.
  • nc -ZV localhost port_number : Check if a specific port is open or not.
  • curl : Outputs Geographical Information, regarding an ip_address.
  • find .-user xyz : Lists all file owned by user ‘xyz’
  • apt-get build-dep package_name: Build all the dependency, automatically while installing any specific package.
  • lsof -iTCP:80 -sTCP:LISTEN. The script, outputs all the service/process using port 80.
  • find -size +100M : This command combination, Lists all the files/folders the size of which is 100M or more.
  • pdftk : A nice way to concatenate a lot of pdf files, into one.
  • ps -LF -u user_name : Outputs Processes and Threads of a user.
  • Startx — :1 (This command creates another new X session).

Leave a Reply

Please log in using one of these methods to post your comment: 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 )

Google+ photo

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

Connecting to %s