Bash commands

From MEPIS Documentation Wiki

Jump to: navigation, search



Here is a list of basic terminal commands that many users will want or need to use at some time. Not included are commands for which an easy GUI method is available (e.g., user commands). For more information, see the Links section.

Common commands

Filesystem navigation

Command Explanation Examples
cd /usr/share Changes current directory to the given path: “/usr/share”. With no argument, cd takes you to your home directory.
pwd Prints on the screen the current working directory path, used to find out where you are working when you forget
ls Lists the contents of the current directory, except for hidden files. Use the -a switch to show hidden files as well, and the -l switch to show details on all files. Often combined with other terms. lsusb lists all the usb devices,

lsmod all the modules, etc.

File management

Command Explanation Examples
cp source.file destination.file Copy a file to another filename or location. Use the -R switch ("recursive") to copy entire directories.
mv source.file destination.file Move a file or directory from one location to another. Also used to rename files or directories and to make a backup, for example before changing a critical file such as xorg.conf. mv xorg.conf xorg.conf_backup
mv trouble.doc problems.doc
rm deleteme.file Delete a file. Use the -R switch to delete a directory, and the -f switch ("force") if you don't want to be prompted to confirm each deletion. rm ThisFileIsNoGood.doc
rm -R /home/YourUserName/OldPictures/
cat file.txt Prints the contents of a file on the screen. Can only use on text files. cat GRUB_M7.txt
cat /etc/X11/rgb.txt
grep Find a given string of characters in a given piece of text, and print the entire line it was on. The grep command is case sensitive by default, use the -i switch to make it case-insensitive. Usually used with a pipe (see Symbols below). lsusb | grep net
cat /etc/X11/ | grep rgb
most More sophisticated file viewer, which features one screenful at a time, up and down scrolling, text searching, line numbers, and other things. Often used in a pipe. NOTE: this replaces less as the default pager in MEPIS Linux 7.0. most.


Command Explanation Examples
| The pipe symbol, used to send the output of one command into the input of another.
> The redirect symbol, used to send the output of a command into a file or device. Doubling the redirect symbol (>>) will cause the output to be added to the end of an existing file rather than replacing it.
& Adding the ampersand to the end of a command (with a space before it) causes it to run in the background, so that you don't have to wait for it to complete to issue the next command. Using double ampersands allows you to run two commands, the second only running if the first was successful.


Command Explanation Examples
lspci Shows a quick summary of detected internal hardware devices. If a devices shows as unknown, you usually have a driver issue. The -v switch causes more detailed information to be displayed.
lsusb Lists attached usb devices.
dmesg Shows the system log for the current session (i.e. since you last booted). The output is quite long, and usually this is piped through grep, less (similar to most) or tail (to see what happened most recently). grep -i net.
ifconfig Shows the status of currently active network interfaces.
iwconfig Shows the status of your wireless network interface.
top Provides a real-time list of running processes and various statistics about them.

Documentation for commands

  • Many commands will print out a simple "usage information" message when you use the "--help" or "-h" switch. This can be helpful for quickly recalling the syntax of a command. For example:
    cp --help
  • For more detailed information on how to use a command, consult the command's man page. Short for “manual,” man pages typically contain detailed information about switches, arguments, and sometimes the inner workings of a command. Even GUI programs often have man pages, detailing available command line options. Manual pages are conveniently viewed in Konqueror by typing man:commandname into the address bar. In addition, by simply typing man:/ into Konqueror, you can browse the entire collection of man pages installed by MEPIS.
  • The man page may also be read at the console with the command man commandname. By default, man pages are displayed in the terminal's most pager, meaning that only one screenful of the file is displayed at a time. Keep these tricks in mind to navigate the resulting screen:
    • The space bar advances the screen.
    • The letter b moves the screen backward.
    • The letter q exits the help document.
    To check if a manual page exists on a particular command or subject use
     man -k subject

    Links and Guides

Personal tools
In other languages