Monday, July 7, 2014

Command Line Tips

Excellent Resource:
https://github.com/0nn0/terminal-mac-cheatsheet/wiki/Terminal-Cheatsheet-for-Mac-(-basics-)

$ Ctrl+A -  to send the cursor to start of the command

$ Ctrl+E - to send the cursor to the end of the command.

$ Ctrl+C - used to quit a running program in terminal

$ Ctrl U - clears the line

$ Ctrl+L - clears the screen while retaining whatever was there on the current prompt

$ Ctrl+R - and write few characters from the start of command you’re looking for


$ echo <whatever> - reads back in the terminal whatever you write

$ cat <filename> - reads the file

$ touch <filename> - creates a new file

$ head -5 output - displays content from the beginning of a file

$ tail -5 output - displays the last five lines from the file ‘output’


$ history | grep "myarticle.txt"

$ rm -rf dirname - to force remove a directory and it's contents

$ ! - runs a previously run command


$ jobs - lists all the commands running in the background !

$ ps - displays a list of the processes you’ve launched

$ fg - bring a specific job back to the foreground

$ kill %<job-number> kills a process by it's job-number in the list or

$ kill<PID> kill a process by is process id (PID) 1234




sudo lsof -i - "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. http://danielmiessler.com/study/lsof/

On a Mac you can 
$ Option + Click - to get to a specific spot in your commandline

For fun:

$ telnet towel.blinkenlights.nl 

http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/


http://www.linuxjournal.com/content/time-saving-tricks-command-line

http://www.linuxuser.co.uk/tutorials/14-command-line-tips-tricks

http://mylinuxbook.com/5-really-cool-linux-command-line-tricks/

https://linuxacademy.com/blog/linux/ten-things-i-wish-i-knew-earlier-about-the-linux-command-line-2/

Blank Terminal Window
http://www.cnet.com/news/os-x-terminal-displays-a-blank-window-instead-of-a-command-prompt/

No comments:

Post a Comment