DEV Community

Cover image for Linux Commands (CLI) To Get You Started
Hillary Nyakundi
Hillary Nyakundi

Posted on

Linux Commands (CLI) To Get You Started

This article deals exclusively with the Command Line Interface(CLI), rather than a Graphical User Interface(GUI) you may be familiar with. A basic understanding of the terminal is essential to diagnosing and fixing most Linux based systems.

What is a command? A command is a software program that when executed on the CLI performs an action on the computer. When you type in a command, a process is run by the operating system that can read input, manipulate data and produce output. It runs a process on the operating system, which then causes the computer to perform a job.

List of Commands

The 'ls' Commands

Most commands follow a simple pattern of syntax:

command [options…] [arguments…]
Enter fullscreen mode Exit fullscreen mode

- to display a listing of information about files you will use

ls
Enter fullscreen mode Exit fullscreen mode

Note: Every part of the command is normally case-sensitive, so LS is incorrect and will fail, but ls is correct and will execute.

- results in a "long display" output, meaning the output gives more information about each of the files listed:

ls -l
Enter fullscreen mode Exit fullscreen mode

- To print results in reverse order alphabetical order use:

ls -r
Enter fullscreen mode Exit fullscreen mode

- To sort files by timestamp:

ls -lt
Enter fullscreen mode Exit fullscreen mode

- To sort files by size use:

ls -l -S
Enter fullscreen mode Exit fullscreen mode

Switch Between Directories Commands

- To print the current working directory use:

pwd
Enter fullscreen mode Exit fullscreen mode

- To change from one directory/folder to another use:

cd [directory name here]
Enter fullscreen mode Exit fullscreen mode

- To move to previous directory use:

cd /
Enter fullscreen mode Exit fullscreen mode

- To move to home/first directory use:

cd ~
Enter fullscreen mode Exit fullscreen mode

Find the rest of the article at my blog HERE

Connect With me at Twitter | Insta | YouTube | LinkedIn | GitHub

Top comments (2)

Collapse
 
ricobrase profile image
Rico Brase

A little correction:

cd / doesn't move to previous directory, but to the filesystem root (e.g. where the folders etc, home and var are located).

To move to the previous directory, you can use:

cd -
Enter fullscreen mode Exit fullscreen mode

And the home directory doesn't necessary have to be the "first directory" (a session can start outside of the users home directory).
cd ~ always changes directory the current users home (which can, but doesn't have to be the "first directory" after login).

Also quite helpful:
To go up one level (e.g. move out of the current folder), you can use:
cd .. - .. means "the directory above the current one".


Still a great overview over the most basic CLI commands on Linux-based operating systems, thank you!

Collapse
 
larymak profile image
Hillary Nyakundi

I appreciate for the correction, thank you