Linux Command Line Basics - Essential Commands & Shortcuts

Master Linux command line basics with this guide to essential commands like man, date, ls, cat, cp, mv, rm, grep, pwd, and cd. Learn navigation and editing shortcuts for efficient terminal use.

Linux Command Line Basics

Linux Command Line Basics

This guide covers essential Linux command-line commands and shortcuts to help you navigate and manage your system efficiently. Understanding these basics is crucial for any developer or system administrator working with Linux environments.

Essential Commands

Here are some of the most frequently used commands in the Linux terminal:

Command Description
man Get help on commands. For example, use man date to see the manual page for the date command.
date Displays the current date and time.
cal Shows the calendar for the current month or a specified month/year.
ls Lists files and directories in the current working directory. When used with the -l option (ls -l), it provides detailed information including owner, size, modification date, and permissions.
cat Displays the contents of a file. It can also be used to concatenate files.
cp Copies files or directories from one location to another.
mv Moves or renames files and directories.
diff Compares two files line by line and reports the differences.
rm Removes (deletes) files or directories. Use with caution, especially with the -r option for directories.
grep Searches for patterns (strings) within one or more files.
pwd Prints the name of the current working directory.
cd Changes the current directory to a specified path.

Command Line Shortcuts

Boost your productivity with these keyboard shortcuts for navigating and editing text in the terminal:

Keyboard Shortcut Description
Ctrl + A Move the cursor to the beginning of the line.
Ctrl + E Move the cursor to the end of the line.
Alt + F Move the cursor forward by one word.
Ctrl + F Move the cursor forward by one character.
Alt + B Move the cursor backward by one word.
Ctrl + B Move the cursor backward by one character.
Ctrl + XX Toggle the cursor's position between the current position and the beginning of the line.

Editing Shortcuts

Keyboard Shortcut Description
Ctrl + U Cut (delete) all characters from the cursor to the beginning of the line.
Ctrl + K Cut (delete) all characters from the cursor to the end of the line.
Ctrl + W Cut (delete) the word to the left of the cursor.
Ctrl + H Delete the character to the left of the cursor (Backspace).
Alt + D Cut (delete) the word to the right of the cursor.
Ctrl + D Delete the character to the right of the cursor (Delete). Also used to exit shells.
Ctrl + Y Paste the most recently cut text.
Ctrl + _ Undo the last deletion or editing action.
Tab Auto-complete commands, file names, and arguments. Pressing it twice often lists all available options.

Recall from History Shortcuts

Keyboard Shortcut Description
Ctrl + R Search backward through the command history. Type part of a command to find it.
Ctrl + G Abort the current search or command line editing operation.
Ctrl + P or UP Arrow Recall the previous command in the history.
Ctrl + N or DOWN Arrow Recall the next command in the history.

Mastering these Linux command-line basics will significantly enhance your efficiency when working in a terminal environment. For more advanced topics, consult the respective man pages for each command.