Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

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 modeExit fullscreen mode

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

ls
Enter fullscreen modeExit 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 modeExit fullscreen mode

- To print results in reverse order alphabetical order use:

ls -r
Enter fullscreen modeExit fullscreen mode

- To sort files by timestamp:

ls -lt
Enter fullscreen modeExit fullscreen mode

- To sort files by size use:

ls -l -S
Enter fullscreen modeExit fullscreen mode

Switch Between Directories Commands

- To print the current working directory use:

pwd
Enter fullscreen modeExit fullscreen mode

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

cd [directory name here]
Enter fullscreen modeExit fullscreen mode

- To move to previous directory use:

cd /
Enter fullscreen modeExit fullscreen mode

- To move to home/first directory use:

cd ~
Enter fullscreen modeExit fullscreen mode

Find the rest of the article at my blogHERE

Connect With me atTwitter |Insta |YouTube |LinkedIn |GitHub

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
ricobrase profile image
Rico Brase
  • Location
    Germany
  • Work
    Software Developer
  • Joined

A little correction:

cd / doesn't move to previous directory, but to the filesystem root (e.g. where the foldersetc,home andvar are located).

To move to the previous directory, you can use:

cd -
Enter fullscreen modeExit 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!

CollapseExpand
 
larymak profile image
Hillary Nyakundi
Growing Developer | Open-Source Advocate | Python Fanatic ❤
  • Location
    Nairobi
  • Work
    Developer at Freelancer
  • Joined

I appreciate for the correction, thank you

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Growing Developer | Open-Source Advocate | Python Fanatic ❤
  • Location
    Nairobi
  • Work
    Developer at Freelancer
  • Joined

More fromHillary Nyakundi

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp