10 Linux commands you probably don't use

by Rekha 2009-10-13 18:33:37

The following Linux command line tips are not typically used by your everyday Linux user.

Quickly Find a PID with pgrep

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.

pgrep ssh


This will list all PIDs associated with the ssh process.

Execute The Last Executed Command

The heading sounds a bit confusing but its exactly what it does.

!!


This will execute the last command you used on the command line.

Execute The Last Command Starting With..

If you want to execute a command a command from history starting with the letter S you can use the following:

!s


This will execute the last command used on the command line that started with 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 youre in a hurry, you can save and quit the file youre editing in vi by exiting insert mode, holding shift, and hitting z twice.

Quickly Log Out of a Terminal

You can quickly log out of a terminal session by using: CTRL+D


Navigate to the Last Directory You Were In

cd - will take you to the last directory you were in.


Make Parent Directories the Smart Way

mkdir -p /home/adam/make/all/of/these/directories/


This will create all directories as needed even if they do not exist. Why waste time doing something silly like: mkdir make ; cd make ; mkdir all ; cd all ; mkdir of ; cd of you get the point. Use mkdir -p!

Delete the Entire Line

If youve just typed a long string of commands that you dont need to enter anymore, delete the entire line by using:
CTRL+U.


Set the 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).

Tagged in:

1225
like
0
dislike
0
mail
flag

You must LOGIN to add comments