General Shell Tips

Automatic Command Completion

Use the TAB key and bash will attempt to complete the command for you automatically. You can use it to complete command (tool) names. You can also use it when working with the file-system, when changing directories, copying files et cetera.

There are also other lesser known ways to use automatic command completion (for example completing user names):[1]

ESCY  (Y: special character)
testing autoindexing Will attempt to complete the command name for you. If it fails it will either list the possible completions (if they exist). If there are none it will simply beep (and/or) flash the screen.

CTRLXY  (Y: special character)
Lists the possible completions (it won’t attempt to complete it for you) or beep if there are no possible completions.


Use the following special characters combined with either ESCY or CTRLXY , where Y is some special characters. For example ESC$ or CTRLX$ to complete an environment variable name.

  • ~ (tilde) complete a user name
  • @ (at sign) complete a machine name
  • $ (dollars sign) complete an environment variable name
  • ! (exclamation mark) a magic character for completing a command name or a file name. The ! special character has the same function as the TAB key. It works in some other situations; for example when completing man page names.


The alias command will list your current aliases. You can use unalias to remove the alias (to disable it just for one command add a “\” (back-slash) before the command)…

An alias allows one command to be substituted for another. This is used to make a command do something else or to automatically add certain options. This can be either be done during one session using the alias command (see below) or the information can be added to the .bashrc file (found in the users home directory).

Below is an example of what an alias section (within your .bashrc file) might look like:

# my personal aliases
alias cp='cp -vi' #to prompt when copying if you want to overwrite and will tell you where information is going 
alias rm='rm -i' #Prompts you if you really want to remove it.
alias mv='mv -i' #Prompts you if you are going to overwrite something

On any Mandriva GNU/Linux system the global aliases (for all users) are all in /etc/profile.d/ The above listed commands already have aliases, as well as several other commonly used commands.

set -x

set is one of bash’s inbuilt commands, try looking in the bash manual for its many usage options.

Using set with the -x option will make bash print out each command it is going to run before it runs it.

This can be useful to find out what is happening with certain commands such as things being quoted that contain wildcards or special symbols that could cause problems, or complex aliases. Use set +x to turn this back off.


After using set -x you can run the command:


The output printed before the command runs (for example):

+ ls -F --color=auto

Which means that the command is really an alias to run ls with the -F and –color=auto options. Use a “\” (backslash) before the command to run it without the alias.

\ (backslash)

The backslash escape character can be used before a shell command to override any aliases.

For example if rm was made into an alias for rm -i then typing “rm” would actually run rm -i.

However, typing \rm lets the shell ignore the alias and just run rm (its runs exactly what you type), this way it won’t confirm if you want to delete things.

Caution Using rm
Please note that the alias for the remove command is there for a reason. Using it incorrectly could remove files which you don’t want removed.

Only use \rm if you know exactly what you are doing (recovering files is not easy, rm does not send things to a recycle bin).

The “\” character can be used before special characters (such as a space or a wildcard), to stop bash from trying to expand them. You can make a directory name with a space in it using a backslash before the space. For example you could type cd My\ Directory\ With\ Spaces which normally wouldn’t work.

The “\” character can also be used to stop bash from expanding certain symbols (as an alternative you could use single quotation marks, although you may need to use both).

Tip The TAB Key
Please note that using the TAB key (automatic-command-completion) will automatically use escapes for spaces (so you don’t have to type them manually).


The “script” command creates a typescript, or “capture log” of a shell session – it writes a copy of your session to a file, including commands you type and their output.

~ (tilde character)

The tilde character is used as an alias to a users home directory.

For example, if your user-name was “fred”, instead of typing cd /home/fred you could simply type cd ~. Or to get to fred’s tmp directory (under his home directory) you could type cd ~/tmp.

Tip Home directory shortcut
~ (tilde) can also be used as a shortcut to other users home directories, simply type: ~user_name and it will take you to the users home directory. Note that you need to spell the username exactly correct, no wildcards.


set bell-style none

This particular set command will turn off the system bell from the command-line (use xset -b for X windows). If you want the bell to stay off pernamently (no audible bell) then you can add this command to your “.bashrc” or “.bash_profile” (just add it to the same one you have your alises in…).


The reset command re-initializes your current terminal. This can be useful when the text from your terminal becomes garbled, simply type “reset” and this will fix your terminal.


Closes your current terminal (with x-terminals) or logs-out. Also try CTRLD .


Logs out of a terminal, also try CTRLD .


A little command that repeats anything you type.


echo “hello world”

Simply displays “ hello world”.


echo rm -R *

This will output what will be passed to the rm command (and therefore what would be deleted), putting echo before a command renders it harmless (it just expands wildcards so you know what it will do).

Also try using the -e option with echo. This will allow you to use the escape character sequences to format the output of a line. Such as ‘\t’ for tab, ‘\n’ for newline etc.

Tip Using echo to prevent accidents
Typing: echo command(s) could save you the trouble of accidentally doing something you didn’t expect.

Using echo allows you to expand the wildcards to understand what will happen before you actually run the command.


GNU/Linux Command-Line Tools Summary

Gareth Anderson

Chris Karakas – Conversion from LyX to DocBook SGML, Index generation

Revision History
Revision 1.2 15th April 2006 Revised by: GA
Corrected typing errors, generated new, much smaller index (more accurate in my opinion). Updated errors in document for TLDP.
Revision 1.1 28th February 2006 Revised by: CK
Corrected typos, generated new index (9000 index entries!).
Revision 1.0 6th February 2006 Revised by: GA
Major restructuring, now in a docbook book format. Removed large chunks of content and revised other parts (removed chapters and sectioned some areas more). This is likely the final release by the author, I hope that someone finds this guide useful as I do not intend to continue work on this guide.
Revision 0.7.1 25th February 2005 Revised by: CK
Set special characters in math mode, produced PDF and PS with Computer Modern fonts in OT1 encoding and created correct SGML for key combinations.
Revision 0.7 5th December 2004 Revised by: GA
Updated document with new grammatical review. Re-ordered the entire Text section. Removed a fair amount of content.
Revision v0.6 20th April 2004 Revised by: GA
Attempted to fix document according to TLDP criticisms. Added notes and tips more sectioning. Now complying to the open group standards for the UNIX
system trademark. Document should be ready for TLDP site.
Revision v0.5 6th October 2003 Revised by: GA
Fixed a variety of errors as according to the review and made some consistency improvements to the document.
Revision v0.4 15th July 2003 Revised by: GA
Made small improvements to the document as suggested (so far) by the thorough TLDP review, improved consistency of document and made small content additions.
Revision v0.3 26th June 2003 Revised by: GA
Minor errors fixed, updated the appendix with information for finding where a tool is from. Fixed referencing/citation problems and improved further reading and intro sections, added an audio section.
Revision v0.2 20th April 2003 Revised by: GA
This is the initial public release. Added more code-style then before, broke text-section into more subsections. Improved consistency of document and fixed various index entries.
Revision v0.1 27th March 2003 Revised by: GA
This is the initial draft release (the first release to be converted from LyX to DocBook SGML).
This document is an attempt to provide a summary of useful command-line tools available to a GNU/Linux based operating system, the tools listed are designed to benefit the majority of users and have being chosen at the authors discretion. This document is not a comprehensive list of every existent tool available to a GNU/Linux based system, nor does it have in-depth explanations of how things work. It is a summary which can be used to learn about and how to use many of the tools available to a GNU/Linux based operating system.

Table of Contents
1. Introduction
1.1. Who would want to read this guide?
1.2. Who would not want to read this guide?
1.3. Availability of sources
1.4. Conventions used in this guide
1.5. Resources used to create this document
1.6. Feedback
1.7. Contributors
2. Legal
2.1. Disclaimer
2.2. License
3. The Unix Tools Philosophy
4. Shell Tips
4.1. General Shell Tips
4.2. The command-line history
4.3. Other Key combinations
4.4. Virtual Terminals and screen
5. Help
6. Directing Input/Output
6.1. Concept Definitions
6.2. Usage
6.3. Command Substitution
6.4. Performing more than one command
7. Working with the file-system
7.1. Moving around the filesystem
7.2. Working with files and folders
7.3. Mass Rename/copy/link Tools
8. Finding information about the system
8.1. Date/Time/Calendars
8.2. Finding information about partitions
9. Controlling the system
9.1. Mounting and Unmounting (Floppy/CDROM/Hard-drive Partitions)
9.2. Shutting Down/Rebooting the System
9.3. Controlling Processes
9.4. Controlling services
10. Managing users
10.1. Users/Groups
11. Text Related Tools
11.1. Text Editors
11.2. Text Viewing Tools
11.3. Text Information Tools
11.4. Text manipulation tools
11.5. Text Conversion/Filter Tools
11.6. Finding Text Within Files
12. Mathematical tools
13. Network Commands
13.1. Network Configuration
13.2. Internet Specific Commands
13.3. Remote Administration Related
14. Security
14.1. Some basic Security Tools
14.2. File Permissions
15. Archiving Files
15.1. tar (tape archiver)
15.2. rsync
15.3. Compression
16. Graphics tools (command line based)
17. Working with MS-DOS files
18. Scheduling Commands to run in the background
19. Miscellaneous
20. Mini-Guides
20.1. RPM: Redhat Package Management System
20.2. Checking the Hard Disk for errors
20.3. Duplicating disks
20.4. Wildcards
A. Appendix
A.1. Finding Packages/Tools
A.2. Further Reading
A.3. GNU Free Documentation License