Basic (but) Useful Linux Commands

Basic (but) Useful Linux Commands

Wikis > Basic (but) Useful Linux Commands

Page Contents

Command Line Basics – Useful Linux Commands

While it is possible to use Bodhi Linux without much knowledge or use of the Command Line Interface (CLI [terminal]) and to stick primarily with the Graphical User Interface (GUI), there are certain tasks that are more efficient/easier to perform via the CLI/terminal. Generally, you will use a terminal emulator (Bodhi Linux’s default is Terminology) to access the CLI/terminal from the GUI.  As you become more proficient with using Bodhi Linux, you may find yourself gravitating toward the CLI/terminal for certain tasks.

Below is a list of some useful commands to get you started!

***CAUTION*** – if you ever enter a command and are asked to authorize via the question, “Yes, do as I say!”, do not run the command. The operation you are attempting is about to purge system critical packages and will generally result in a non-usable system. You have been warned!***

Basic Commands

sudosuperuser do – allows a user to run commands/programs with the privileges of another user, by default root or admin – use when programs request “elevated privileges”

Note: In Bodhi Linux, the sudo password is your login password by default. 

aptAdvanced Package Tool – used to get and install packages/programs – replaces apt-get

update – lets package manager know about available packages/programs and their versions; does not install anything.

upgrade – will upgrade versions for packages/programs from the update but will not remove anything nor update dependencies not already installed.

dist-upgrade – will upgrade versions for packages/programs and will intelligently install/remove packages as necessary to complete the upgrade.

For more details see: Keeping Bodhi Software Updated

Examples:

sudo apt update && sudo apt dist-upgrade

sudo apt install cups

Useful Terminal Hotkey Combinations

<ctrl>+<shift>+<c> copy

<ctrl>+<shift>+<v> paste

<ctrl>+<r> searches command line history

<ctrl>+<l> clears the terminal (lower case ‘L’)

<ctrl>+<u> erases entire line to the left of cursor

<ctrl>+<k> erases to the right

<ctrl>+<w> erases one word left

<ctrl>+<d> logout or exit

Commands that are Generally Useful to Know

cat – concatenate, read or modify a file; used to display the contents of a file

cd – change directory; used to change your working directory

chmod – change permissions; used to change the permissions of a file/directory.

Note: you must own the file or be sudo for this command

cp – copy; used to copy files/directories

df – shows the amount of disk space used and available on mounted file systems

du – shows the amount of disk space used by specified files/directories

exit – exits the terminal

find – searches directory for files that meet criteria (–name, searches by name; –type, by file type; –size, by file size)

grep – searches file for specific character strings/patterns and can be used to replace a string with another string

ifconfig – view network settings

less – used to view a file vs. opening a file – compared to the more command, less allows backward and forward movement w/in the file, line by line or by page (can be useful to pipe commands to less [the pipe symbol is the straight-line about your enter key; | ]).

ln – used to create a hard or symbolic link to a file

ls – lists files or directories

man – manual; displays built-in documentation/user manual within Bodhi/Linux – commands, how to, syntax, etc

mkdir – make directory; used to make an empty directory

more – used to view a file vs. opening a file – page by page scrolling

mv – move; used to move a file/directory

netstat – network statistics; displays info/statistics about network protocols in use and TCP/IP connections

passwd – password; used to change a user’s own password (admin may change anyone’s password)

ping – used to test a connection to a host/IP address

pwd – print working directory; displays your current working directory

rm – remove; used to remove/delete files

rmdir – remove directory; used to remove empty directories

shutdown – used to shutdown/halt/restart system (ex: sudo shutdown - r now will restart your system)

top – task manager program used to monitor system tasks/processes and system resource usage (CPU utilization, memory usage, run times) in real-time, with sorting possible

touch – used to create a blank file

uname – reports basic information about your environment (ex: uname -a will report kernel name, node name, kernel release, kernel version, machine, processor, hardware platform, and OS)

whoami – prints user/login name associated with the current user ID

Commands Options

-a, --all – all; shows all information (including hidden) or operates on all arguments

* – asterisk/splat; wildcard

! – exclamation/bang; in scripts, means “not”

!!– repeats last command in terminal

-f – force; force copy by removing destination file if needed

CAUTION: can authorize potentially destructive actions for which a command/program would generally request user confirmation before completing

-h--help – help; provides usage messages and assistance

-i – interactive; prompts before overwrites, etc

-l, --list – list; lists files or arguments

|, – pipe; sends the output of one command/program to another command/program for further processing

Note: the pipe symbol is not an “L” – it is available via <shift>+<\> (backslash) key on most QWERTY keyboards

-r, -R, --recursive – recursive/reverse; operates a command recursively/down the directory tree

-u, --update; move when the source is newer than the destination

-v, --verbose – verbose; output additional information

-y, --yes; enters yes into a command string –

CAUTION: can authorize potentially destructive actions for which a command/program would generally request user confirmation before completing

Commands for Directory Navigation

/ – root directory

/home – home directory for the current user

cd – change directory (when used without providing a directory, will take you to your home directory)

cd  ~– takes you to your home directory

cd .. – move up one level (the parent directory of current)

cd ../../ – move up two levels

cd -– will take you to where you were previously

Tip: Have a difficult time remembering commands? Press the up arrow key in Terminology to display commands you have previous run from your terminal history – press up until you find your needed command/s then press enter!

Bodhi Linux Home
Bodhi Linux – Wiki Home Page
Bodhi Linux – Wiki Table of Contents

Category: Tags: