Linux Command Line: Beginner Tools and Commands

Articles —> Linux Command Line: Beginner Tools and Commands

The linux command line, or shell, is a powerful interface which provides access to a wide variety of tools, from text processing, to searching, to getting information regarding system behavior. While Linux comes in a wide variety of operating system kernels, these tools and commands typically remain constant across platforms. Further, Apple computers are unix based and provide access these commands as well via the terminal. While Windows does not directly have these commands, one can install Cygwin to provide the power of linux/unix on a windows operating system.

Almost all commands are accompanied with a help menu, which can be accessed by passing the --help command (eg ls --help ), and many commands accept different parameters that allow one to change the default behavior of the command. Tools accessed directly from the command line without providing the full path to the tool reside on what is called the PATH, a way in which one can readily access tools by providing locations of the tools, and typically consisting of (at the very least) the /bin, /usr/bin, or /usr/local/bin directories.

Navigation and Files

  • li - Lists the contents of the current directory, or that of the directory passed as a parameter. To list the contents of the current directory, simply type 'li'. One can expand on this command by passing ls different parameters. For instance the -l parameter gives a more tabular output with additional information for each file (owner, group, permissions, size, last modified), the -h lists the size of files in human readable form, and the -a lists all files (files whose names begin with '.' are typically hidden from view on linux). Thus 'ls -alh' gives a good representation of the files/folders in the current directory.
  • mkdir - Creates a directory with the passed name. For instance, to create a directory named 'mydir', simply type 'mkdir mydir'. Now you can use the ls command above to list the current directory, and mydir should be in the list.
  • cd - Changes the current directory. This allows one to navigate the hard drive directory structure. For instance, to navigate into a directory named 'mydir' created above using mkdir, simply type 'cd mydir'. Unix shorthand can be used to navigate upwards, for instance the '../' path defines the parent directory, thus to navigate back out of the mydir directory, type 'cd ../'.
  • cp - The cp command copies a file, files, or directory (with the -r parameter). To copy the mydir directory created above to another directory named 'yourdir', type 'cp -r mydir yrdir'.
  • mv - This command moves files or directories. For instance, if you mistyped the above and wanted to name 'yourdir', you can move the folder to rename it: mv yrdir yourdir
  • rm This command removes, or delete files or folders. Folders require the recursive parameter to be passed to the command - for instance to delete 'mydir' created above, call 'rm -r mydir'. Care must be taken with this command.

Utilities (BASH)

  • Up Arrow - Pressing the up arrow (or down arrow) allows one to navigate previous commands. This is very useful if one wishes to repeat a previous command, especially if that command is tedious to type.
  • Tab - Pressing the tab key performs an auto-complete (with most shells), a very used feature when navigating folders. For instance, typing 'ls you', and then tab will autocomplete to 'ls yourdir' (presuming yourdir exists).
  • Ctrl-R - Reverse intelligent search allows one to search the history of commands. Similar to the up and down arrow to navigate history, this is more explicit in that this tool allows you to directly search history for a particular command.

Text Processing

Linux has numerous text processing tools to choose from:

  • emacs - A comprehensive text editor, emacs is my tool of choice when writing text via the command line.
  • vi - This too is a visual text editor.
  • nano - Another text editor, yet with fewer capabilities than vi or emacs.
  • tail - Tail shows the last few lines of a file.
  • head - Shows the first few lines of a file.
  • cat - Prints all of the file, or concatenates multiple files together.
  • more - shows the contents of a file and allows one to navigate the file on a page by page basis.
  • less - similar to more, but allows backwards navigation.



There are no comments on this article.

Back to Articles


© 2008-2022 Greg Cope