Skip to content

Instantly share code, notes, and snippets.

@tylerodin
Last active June 16, 2025 14:36
Show Gist options
  • Save tylerodin/bea5c865513da4a68402299abc1fd045 to your computer and use it in GitHub Desktop.
Save tylerodin/bea5c865513da4a68402299abc1fd045 to your computer and use it in GitHub Desktop.
Top 10 Linux Commands Everyone Should Know

🐧 Top 10 Linux Commands Everyone Should Know


1. ls β€” List directory contents

Displays files and folders in the current directory.

ls           # Basic listing
ls -l        # Long listing format
ls -a        # Show hidden files

2. cd β€” Change directory

Navigate between folders.

cd /path/to/folder
cd ..        # Go up one level
cd ~         # Go to home directory

3. pwd β€” Print working directory

Shows the full path to your current location.

pwd

4. cp β€” Copy files and directories

Duplicate files or entire directories.

cp file.txt /new/location/
cp -r folder/ /new/location/

5. mv β€” Move or rename files

Used for moving or renaming files.

mv oldname.txt newname.txt
mv file.txt /new/location/

6. rm β€” Remove files or directories

Deletes files or folders permanently.

rm file.txt
rm -r folder/        # Delete a directory and its contents

⚠️ Warning: There’s no undo.


7. touch β€” Create empty files

Creates a new file or updates the timestamp of an existing one.

touch newfile.txt

8. cat β€” View contents of a file

Displays the entire content of a file.

cat file.txt

For long files, consider using less or more.


9. sudo β€” Run as superuser

Gives you elevated privileges for administrative tasks.

sudo apt update
sudo rm -rf /restricted/area

Requires your user password.


10. man β€” Manual pages

Displays help documentation for commands.

man ls
man grep

Use the arrow keys to scroll, and q to quit.


βœ… Bonus Tip

Combine commands with pipes and redirection:

ls -l | grep "filename"
echo "Hello" > file.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment