Linux Command Line Basics

Linux Command Line Basics


As a beginner, you might find the Linux command line intimidating at first. But don’t worry, with practice, you’ll become comfortable using these commands in no time!

Updating and Upgrading Linux

Before we dive into file manipulation and other advanced topics, it’s essential to keep your Linux system up-to-date.

Update Package List

sudo apt update

Upgrade All Packages

sudo apt full-upgrade

Note: For Red Hat-based systems, use sudo yum update instead of apt.

Basic File Manipulation

Here are some fundamental file manipulation commands you should know:

Move a File

mv file.txt /home/user/Documents

Copy a File

cp file.txt /home/user/Documents

Remove a File Permanently

rm file.txt

Be cautious when using this command, as it can’t be undone!

Best Practices with Sudo

When using the sudo command, remember:

  • Use sudo only when necessary.
  • Avoid using sudo to run scripts or programs that don’t require elevated privileges.
  • When prompted for a password, enter it carefully. Don’t leave yourself logged in as root!

Other Essential CLI Commands

Some other useful Linux CLI commands include:

Change Directory

cd /home/user/Documents

List Files and Directories

ls

Create a New Directory

mkdir my_new_directory