<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://deltanine.net/mw/index.php?action=history&amp;feed=atom&amp;title=Linux_CLI_commands_and_tips</id>
	<title>Linux CLI commands and tips - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://deltanine.net/mw/index.php?action=history&amp;feed=atom&amp;title=Linux_CLI_commands_and_tips"/>
	<link rel="alternate" type="text/html" href="https://deltanine.net/mw/index.php?title=Linux_CLI_commands_and_tips&amp;action=history"/>
	<updated>2026-06-12T00:01:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.1</generator>
	<entry>
		<id>https://deltanine.net/mw/index.php?title=Linux_CLI_commands_and_tips&amp;diff=597&amp;oldid=prev</id>
		<title>Chris: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://deltanine.net/mw/index.php?title=Linux_CLI_commands_and_tips&amp;diff=597&amp;oldid=prev"/>
		<updated>2013-07-25T08:08:11Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 08:08, 25 July 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Chris</name></author>
		
	</entry>
	<entry>
		<id>https://deltanine.net/mw/index.php?title=Linux_CLI_commands_and_tips&amp;diff=596&amp;oldid=prev</id>
		<title>Chris at 10:00, 20 August 2009</title>
		<link rel="alternate" type="text/html" href="https://deltanine.net/mw/index.php?title=Linux_CLI_commands_and_tips&amp;diff=596&amp;oldid=prev"/>
		<updated>2009-08-20T10:00:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Navigate==&lt;br /&gt;
*Ctrl-a 	Move to the start of the line.&lt;br /&gt;
*Ctrl-e 	Move to the end of the line.&lt;br /&gt;
*Alt-] x 	Moves the cursor forward to the next occurrence of x.&lt;br /&gt;
*Alt-Ctrl-] x 	Moves the cursor backwards to the previous occurrence of x.&lt;br /&gt;
*Ctrl-u 	Delete from the cursor to the beginning of the line.&lt;br /&gt;
*Ctrl-k 	Delete from the cursor to the end of the line.&lt;br /&gt;
*Ctrl-w 	Delete from the cursor to the start of the word.&lt;br /&gt;
*Ctrl-y 	Pastes text from the clipboard.&lt;br /&gt;
*Ctrl-l 	Clear the screen leaving the current line at the top of the screen.&lt;br /&gt;
*Ctrl-x Ctrl-u 	Undo the last changes. Ctrl-_&lt;br /&gt;
*Alt-r 	Undo all changes to the line.&lt;br /&gt;
*Alt-Ctrl-e 	Expand command line.&lt;br /&gt;
*Ctrl-r 	Incremental reverse search of history.&lt;br /&gt;
*Alt-p 	Non-incremental reverse search of history.&lt;br /&gt;
*!! 	Execute last command in history&lt;br /&gt;
*!abc 	Execute last command in history beginning with abc&lt;br /&gt;
*!n 	Execute nth command in history&lt;br /&gt;
*^abc^xyz 	Replace first occurrence of abc with xyz in last command and execute it&lt;br /&gt;
&lt;br /&gt;
==Quickly Find a PID with pgrep==&lt;br /&gt;
&lt;br /&gt;
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pgrep ssh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
- This will list all PIDs associated with the ssh process.&lt;br /&gt;
&lt;br /&gt;
==Execute The Last Executed Command==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will execute the last command you used on the command line.&lt;br /&gt;
&lt;br /&gt;
Isn't the UP arrow for that?&lt;br /&gt;
&lt;br /&gt;
The !! command is very useful when you forget to start a command with sudo :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt-get update&lt;br /&gt;
sudo !!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Execute The Last Command Starting With ...==&lt;br /&gt;
&lt;br /&gt;
If you want to execute a command from history starting with the letter S you can use the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
!s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
- This will execute the last command used on the command line that started with s.&lt;br /&gt;
&lt;br /&gt;
==Last Argument==&lt;br /&gt;
&lt;br /&gt;
You can use the last argument from the last command by refering to it as $_&lt;br /&gt;
&lt;br /&gt;
so you only need to type a long path like this once:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cp assignment.htm /home/phill/reports/2008/&lt;br /&gt;
cd $_&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to go straight to the 2008 folder as well.&lt;br /&gt;
&lt;br /&gt;
You can use this however you like. Always the last argument of the command above.&lt;br /&gt;
&lt;br /&gt;
Like using $_ for the last argument of the last command, you can also hit ALT+. to quickly paste it at the cursor.&lt;br /&gt;
&lt;br /&gt;
==Run a Command Repeatedly and Display the Output==&lt;br /&gt;
&lt;br /&gt;
watch runs a command repeatedly, displaying its output. 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.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
watch -d ls -l&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
- This will watch the current directory for any file changes and highlight the change when it occurs.&lt;br /&gt;
&lt;br /&gt;
==Save Quickly in VI/VIM==&lt;br /&gt;
&lt;br /&gt;
Save and quit the file you’re editing in vi by exiting insert mode, holding shift, and hitting z twice (ZZ). That is quick or not, it depends.&lt;br /&gt;
&lt;br /&gt;
You can use :wq OR more easily :x&lt;br /&gt;
&lt;br /&gt;
==Quickly Log Out of a Terminal==&lt;br /&gt;
&lt;br /&gt;
You can quickly log out of a terminal session by using: CTRL+D&lt;br /&gt;
&lt;br /&gt;
==Navigate to the Last Directory You Were In==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd –&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
will take you to the last directory you were in.&lt;br /&gt;
&lt;br /&gt;
==Make Parent Directories the Smart Way==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p /home/adam/make/all/of/these/directories/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
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 ! This is one command I really lacked.&lt;br /&gt;
&lt;br /&gt;
==Delete the Entire Line==&lt;br /&gt;
&lt;br /&gt;
If you’ve just typed a long string of commands that you don’t need to enter anymore, delete the entire line by using: CTRL+U,K. That is not easy. CTRL+U deletes whatever is to the left of the cursor and CTRL+K deletes what is to the right. If you are at the end of command, CTRL+U will do. Especially if you start typing password and you make a mistake. Alternatively, you can use CTRL+C, which discards the current typed command, and gives you a new line.&lt;br /&gt;
CTRL+L will clear the screen.&lt;br /&gt;
&lt;br /&gt;
==Set the Time stamp of a File==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
touch -c -t 0801010800 filename.c &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
will show the time stamp as 2008-01-01 8:00. The format is (YYMMDDhhmm).&lt;br /&gt;
&lt;br /&gt;
==Command to File==&lt;br /&gt;
&lt;br /&gt;
fc will open the last command from your shell history in the default editor. You can also specify a text editor. You can add a history line number or the first few letters of the most recent command.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fc -e kate wget&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
- will open kate with the last shell command starting with wget. You can edit the command, and when you save and close kate, the command will execute.&lt;br /&gt;
&lt;br /&gt;
==Ampersand==&lt;br /&gt;
&lt;br /&gt;
Ending a command with &amp;amp; runs the command with a new PID, releasing the command line back to you. Useful for running a background process.&lt;br /&gt;
&lt;br /&gt;
==Resetting your session==&lt;br /&gt;
&lt;br /&gt;
Instead of killing and re-starting your terminal session, you can merely type the command reset. This will reset your terminal back to its defaults, clear the screen, and everything will be as it was before.&lt;br /&gt;
&lt;br /&gt;
==Find and Replace in previous command==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
^find[^replace[^append]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It looks for the first occurrence of [find] in the last command and substitutes it with [replace].&lt;br /&gt;
&lt;br /&gt;
stupid example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lulz@localhost:~$ cp /mnt/networkshare/pub/tehcodes.tar.gz .&lt;br /&gt;
cp: cannot stat '/mnt/networkshare/pub/tehcodes.tar.gz': No such file or directory&lt;br /&gt;
lulz@localhost:~$ ^teh^the&lt;br /&gt;
cp /mnt/networkshare/pub/thecodes.tar.gz .&lt;br /&gt;
lulz@localhost:~$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
~% touch CapitalizedFilename&lt;br /&gt;
~% mv zCapitalizedFilename lowercase&lt;br /&gt;
mv: cannot stat `zCapitalizedFilename': No such file or directory&lt;br /&gt;
zsh: exit 1     mv zCapitalizedFilename lowercase&lt;br /&gt;
~% ^z&lt;br /&gt;
mv CapitalizedFilename lowercase&lt;br /&gt;
~% mz lowercase&lt;br /&gt;
zsh: command not found: mz&lt;br /&gt;
zsh: exit 127   mz lowercase&lt;br /&gt;
~% ^z^v^ lower_case&lt;br /&gt;
mv lowercase lower_case&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chris</name></author>
		
	</entry>
</feed>