DiyMediaServer
Featured image of post Master the Basics - The 10 Most Important Linux Commands and How to Use Them

Master the Basics - The 10 Most Important Linux Commands and How to Use Them

Master These 10 Linux Commands to Level Up Your Skills

You’ve installed Linux on your new media server and you’re staring at a prompt like this:

john@mediaserver:~$

A blinking cursor and no idea what to type. If you’re new to the terminal, that little prompt feels like a black box. Cryptic commands, weird symbols, infinite options. It’s intimidating.

Here’s the good news. You don’t need to know hundreds of commands. You need ten. The ten in this post are the ones I use every single day on Debian and Ubuntu boxes to keep media servers running. Learn these and you’ll have the confidence to navigate, manage, and unscrew almost any Linux system you touch.

Think of it like learning a new language. You don’t need the whole dictionary to order a beer. A handful of solid verbs gets you a long way. Same idea here.

I run these commands daily on Debian 12 and Ubuntu 24.04 servers hosting Plex, Jellyfin, and the *arr stack. Everything below works the same on both.

1. ls - List Directory Contents

ls is the first command anyone should learn. It shows you what’s in a directory. That’s it. The Linux equivalent of opening a folder in a file manager, except faster.

Basic Usage

Type ls and it prints the files and folders in your current working directory.

Useful Options

  • ls -l: Detailed view. Permissions, owner, group, size, last modified date.
  • ls -a: Shows hidden files and directories (the ones starting with a dot, like .config).
  • ls -h: Human-readable file sizes (KB, MB, GB) when paired with -l.

Practical Examples

See what’s in a directory: Running ls /media/Movies shows every file in that folder. Useful when you can’t remember if you already imported that movie.

Spot hidden config files: Most app config lives in dotfiles. Use ls -a when you’re troubleshooting or trying to find where some daemon hid its settings.

Check file details: When permissions or size matter (is this script executable? Did this download finish?), ls -lh gives you everything in one shot.

Why It Matters

You can’t manage what you can’t see. ls is how you see. Get comfortable with it first, because every other command in this list assumes you know what’s actually on disk.

2. cd - Change Directory

cd is how you move around. It stands for “change directory,” which is exactly what it does. Think of it as double-clicking a folder, except your hands never leave the keyboard.

Basic Usage

cd <directory>: Move into that directory.

Want to jump to your Movies folder?

cd /media/Movies

Useful Shortcuts

Home directory: cd on its own takes you back home, no matter where you are.

Parent directory: cd .. moves you one level up.

Root directory: cd / drops you at the top of the file system.

Previous directory: cd - jumps back to wherever you were before the last cd. This one’s a lifesaver when you’re bouncing between two folders.

Practical Examples

Jump to an absolute path:

cd /media

Jump straight to a nested folder, no need to walk down step by step:

cd /media/Shows

Back up one level:

cd ..

Why It Matters

You’ll run cd more than any other command. Efficient navigation is the difference between feeling lost and feeling in control. Learn it cold.

Troubleshooting

If cd errors out, check the directory name. Linux file systems are case-sensitive. media and Media are two different folders. Run ls first to confirm what’s actually there.

3. pwd - Print Working Directory

pwd stands for “print working directory.” It tells you exactly where you are in the file system. Think of it as the “you are here” arrow on a mall map.

Basic Usage

Type pwd and you get the full absolute path of your current directory.

If you’re in your Movies folder, pwd returns:

/media/Movies

Practical Use Cases

Know where you are: After three SSH sessions and ten cd commands, it’s easy to lose track. pwd ends the guessing.

Script writing: When you write a shell script that builds relative paths, pwd confirms you’re starting from the right place.

Debugging: A command not working? Half the time you’re in the wrong directory. pwd tells you in one second.

Why It Matters

It’s a small command, but it’s the one you reach for when you’re confused. Pair it with ls and cd and you can always orient yourself.

Example Workflow

  1. You SSH into a remote server and don’t know where you landed. Run pwd.
  2. You’ve changed directories five times. Run pwd again before you copy or delete anything.

Tips

You can drop it into scripts to log the current directory:

echo "You are currently in $(pwd)"

Useful when creating symbolic links or setting environment variables. If you’re not sure where you are, you can’t be sure where the link will point.

4. mkdir - Make Directory

mkdir creates new directories. Whether you’re laying out your media library or staging a backup folder, this is your tool.

Basic Usage

mkdir <directory-name>

This creates a directory in your current location.

mkdir media

That creates a folder called media right where you are.

Practical Use Cases

Build a media library structure in one command:

mkdir -p /media/{Movies,Shows,Music}

That builds the media folder (if it doesn’t already exist) and creates Movies, Shows, and Music inside it. One line, three folders, no clicking.

Spin up a temp folder for scratch work:

mkdir temp_files

Useful Options

-p (Parent): Creates parent directories as needed. Saves you from “no such file or directory” errors when the path doesn’t exist yet.

-v (Verbose): Confirms each directory as it’s created. Handy when you’re building deep trees.

mkdir -pv /media/{Movies,Shows,Music}

Output:

mkdir: created directory 'media'
mkdir: created directory 'media/Movies'
mkdir: created directory 'media/Shows'
mkdir: created directory 'media/Music'

Troubleshooting

  • “Permission denied”? You don’t have write access where you’re trying to create the folder. Use sudo mkdir for system locations like /etc or /var. But think before you sudo.
  • Typos. Linux is case-sensitive, so media and Media are not the same folder.

Why It Matters

You’ll create directories constantly. Setting up a Plex library, staging downloads, organizing backups. mkdir -p is one of those small tools you’ll use hundreds of times and never think about. Until you forget the -p flag and curse at “No such file or directory” for the tenth time.

5. rm - Remove Files or Directories

rm deletes files and directories. It stands for “remove.” It does not move things to a trash can. It does not ask “are you sure?” by default. Files go away. Forever.

Read that paragraph twice before you run rm on anything you care about.

Basic Usage

To remove a file:

rm <file-name>

For example:

rm old_document.txt

Gone.

Deleting Multiple Files

You can list several files in one command:

rm file1.txt file2.txt file3.txt

Removing Directories

By default, rm won’t touch directories. You need flags.

rm -r (Recursive): Removes a directory and everything in it.

rm -r folder_name

rm -rf (Recursive + Force): Deletes everything, no prompts, no warnings.

rm -rf /path/to/directory

This one earned the nickname “the nuclear option” for a reason. I’ve watched people run rm -rf on / because of a stray space. Once it’s running, you can’t get it back. Be deliberate.

Practical Use Cases

Clean up after testing:

rm -r /tmp/my_temp_files

Drop a movie you’ll never watch again:

rm -r /media/Movie/Movie_I_No_Longer_Need

Useful Options

-i (Interactive): Asks before deleting each file. Slow, but it’ll save you the day you mistype a path.

rm -i important_file.txt

-v (Verbose): Prints what it’s deleting.

rm -rv /path/to/directory

-f (Force): Ignores warnings and deletes without asking. Combine with -r only when you’re certain.

Safety Tips

  1. Double-check the path. Always. If you can’t read the path out loud and feel confident, don’t run the command.
  2. Avoid sudo unless you need it. Running rm as root can wipe system files. Use it sparingly.
  3. Preview with ls first. Run ls /path/to/directory before rm -r /path/to/directory. Confirm you’re looking at the right files.

Why It Matters

Cleanup is part of running a server. Logs grow, downloads pile up, old configs linger. rm keeps the system tidy. But every Linux user has an rm -rf horror story. Don’t earn yours.

Example Workflow

  1. Delete a single file:
rm Movie_I_Hate.mkv
  1. Remove a directory and its contents:
rm -r ~/Downloads/temp_folder
  1. Clean all .tmp files in a directory:
rm *.tmp

6. cp - Copy Files and Directories

cp copies files and directories. Backups, duplicates, config snapshots before you mess with something. You’ll reach for this one constantly.

Basic Usage

Copy a file:

cp <source-file> <destination>
cp config.conf backup_config.conf

This copies config.conf to backup_config.conf in your current directory. Cheap insurance before editing.

Copying Multiple Files

cp file1.txt file2.txt /path/to/destination/

Copying Directories

cp won’t copy directories without the recursive -r flag:

cp -r /source/directory /destination/directory

That duplicates the whole tree, subdirectories and all.

Practical Use Cases

Snapshot a config before editing:

cp config.yaml config_backup.yaml

If you break the edit, you have a known-good copy to restore.

Copy media between folders or drives:

cp /home/user/downloads/movie.mkv /media/Movies/Movie_Name/

Useful Options

-i (Interactive): Asks before overwriting existing files.

cp -i file1.txt /destination/

-v (Verbose): Shows each file as it copies. Helpful on large operations.

cp -v file1.txt file2.txt /destination/

-u (Update): Only copies if the source is newer or the destination file doesn’t exist. Great for syncing.

cp -u file1.txt /destination/

-p (Preserve): Keeps timestamps, permissions, and ownership.

cp -p file1.txt /destination/

Tips

Preview first: Use ls to confirm both source and destination paths before running cp.

Avoid overwrites: Use -i to prompt before clobbering, or -n (no-clobber) to skip overwrites entirely.

Why It Matters

Anytime you’re about to edit something important, copy it first. cp config.yaml config.yaml.bak takes one second and has saved me more times than I can count. Cheap insurance.

7. mv - Move or Rename Files and Directories

mv does two jobs. It moves files and directories, and it renames them. Same command, depending on where the destination points.

Basic Usage

Move a file:

mv <source-file> <destination>
mv movie.mkv /media/Movies/Movie_Name/

This moves movie.mkv into the Movie_Name directory.

Rename a file:

mv <old-name> <new-name>
mv Movie_Name.mkv Movie_Name_2022.mkv

Same command, different destination. Linux treats a rename as a move within the same directory.

Moving Multiple Files

mv file1.txt file2.txt file3.txt /destination/directory/

Moving Directories

Move an entire directory:

mv /source/directory /destination/

Whole tree, one command.

Useful Options

-i (Interactive): Prompts before overwriting.

mv -i file.txt /destination/

-v (Verbose): Shows each move or rename.

mv -v file.txt /destination/

-n (No-Clobber): Won’t overwrite existing files at the destination.

mv -n file.txt /destination/

Tips

Preview first: Use ls or find to check what you’re about to move. A bad mv on a system file can break things in unexpected ways.

Avoid overwrites: -i or -n will save you when the destination has a file you forgot about.

Be careful with sudo: Moving system files as root can break boot. Read your command twice before you hit Enter.

Why It Matters

mv is fast and irreversible. Move a config to the wrong place and your daemon won’t start. But used carefully, it’s how you keep a server organized. Rename a misnamed download, shuffle a folder to a new drive, restructure a media library. All mv.

8. chmod - Change File Permissions

chmod controls who can read, write, and execute a file. It’s how Linux keeps users out of each other’s stuff and stops accidental damage to system files. If you’ve ever copied a script and gotten “Permission denied,” chmod is the fix.

Understanding File Permissions

Before touching chmod, look at what permissions actually look like. Run ls -l on a file:

-rwxr-xr--  1 user group 4096 Jan 23 10:00 script.sh

Three letters, three categories:

  • r (read): View the file’s contents.
  • w (write): Modify the file.
  • x (execute): Run the file as a program or script.

Three categories of users:

  1. Owner (rwx) - Full access.
  2. Group (r-x) - Read and execute for group members.
  3. Others (r--) - Everyone else can only read.

Basic Usage

Symbolic notation:

chmod <permissions> <file>

Give the owner execute permission:

chmod u+x script.sh

Symbolic targets:

  • u (user): The file’s owner.
  • g (group): Users in the file’s group.
  • o (others): Everyone else.
  • a (all): Applies to u, g, and o.

Modifiers:

  • + (add): Adds a permission.
  • - (remove): Removes a permission.
  • = (set): Sets a permission exactly.

Add read and write for the group:

chmod g+rw file.txt

Remove execute for others:

chmod o-x script.sh

Octal notation:

Faster once you know it. Numbers map to permission bits:

  • 4 (read): r--
  • 2 (write): -w-
  • 1 (execute): --x

Add them up. 7 = rwx, 6 = rw-, 5 = r-x.

chmod 755 script.sh

That sets:

  • Owner: Read, write, execute (7 = rwx).
  • Group: Read, execute (5 = r-x).
  • Others: Read, execute (5 = r-x).

Practical Use Cases

Make a script executable:

chmod +x my_script.sh

Lock down a sensitive file:

chmod 600 private_file.txt

Only the owner can read or write. Everyone else is shut out.

Open a file for group collaboration:

chmod g+rw shared_file.txt

Useful Options

-R (Recursive): Applies permissions to a directory and everything inside.

chmod -R 755 /path/to/directory

--reference: Copies permissions from one file to another.

chmod --reference=source_file target_file

Example Workflow

  1. Check current permissions:
ls -l file.txt
  1. Modify permissions. Grant read and write to the owner and group, deny everything to others:
chmod 660 file.txt
  1. Open a directory and everything inside:
chmod -R 755 /media/Movies

Tips

Test on one file first. Don’t run chmod -R on a directory tree until you’ve confirmed the result on a single file. Recursive permission changes are hard to unwind.

Don’t use 777. It opens the file to every user on the system. I know it makes the “Permission denied” error go away. It also makes every security audit cry. For shared media folders I use 770. Owner and group get full access, everyone else gets nothing. Files stay protected and invisible to outsiders.

Check regularly: Use ls -l to confirm permissions are what you expect, especially after big copies or moves.

Why It Matters

Permissions are where Linux security starts. chmod is how you control it. Get this one wrong on a media server and either nothing works or the world can read your config files. Take the time to understand it.

9. chown - Change File Ownership

chown changes who owns a file or directory. Every file in Linux has two ownership attributes: a user and a group. chown lets you reassign both. Critical for multi-user systems and for fixing the “why can’t Plex read this folder” problem after a copy from somewhere else.

Basic Usage

Change the owner of a file:

chown <new-owner> <file>
chown kryptikwurm movie.mkv

That sets the owner of movie.mkv to kryptikwurm.

Change both owner and group:

chown <new-owner>:<new-group> <file>
chown kryptikwurm:media movie.mkv

Owner becomes kryptikwurm, group becomes media.

Changing Ownership of Directories

Use -R (recursive) to apply ownership to a directory and everything inside:

chown -R kryptikwurm:media /media

That changes ownership on /media and every file and subfolder inside it.

Useful Options

-R (Recursive): Applies changes to a directory tree.

chown -R kryptikwurm:media /media

-v (Verbose): Prints each change as it happens.

chown -v kryptikwurm:media movie.mkv

Checking File Ownership

Use ls -l before and after:

ls -l file.txt

Output:

-rw-r--r--  1 user group 4096 Jan 23 12:00 file.txt

The first name is the owner, the second is the group.

Safety Tips

Be careful with sudo: Double-check the path. A chown on the wrong directory can lock you out of system files until you fix it.

No wildcards on root paths: chown -R user:group /* will trash your system. Don’t.

Preview first: Use ls -l to inspect ownership before changing it.

Why It Matters

Proper ownership is how Linux decides what a service can read and write. Use chown to:

  • Let the right user account access your media folders.
  • Hand a shared folder to a group so multiple users can collaborate.
  • Fix permission errors after migrating data between machines.

Get ownership right and most of your “Plex can’t see this folder” or “Sonarr can’t write to this directory” headaches disappear.

10. df - Display Disk Space Usage

df shows how much disk space you have. Short for “disk free.” Run it before you launch a big download. Run it when a service mysteriously stops writing. Run it when the server feels slow. It’s a thirty-character command that catches a lot of problems early.

Basic Usage

df

Example output:

Filesystem     1K-blocks     Used       Available  Use%   Mounted on
/dev/sda1       500000000    250000000  250000000   50%   /
tmpfs           4000000      0          4000000      0%   /dev/shm

Key Fields

Filesystem: The disk or storage device (/dev/sda1).

1K-blocks: Total space in 1KB blocks. Ugly. Use -h.

Used: Space currently in use.

Available: Space free.

Use%: Percentage in use. The number that actually matters.

Mounted on: Where the filesystem is mounted in the directory tree.

Useful Options

-h (Human-Readable): Show sizes in MB, GB, TB.

df -h

Output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       500G  250G  250G  50% /

-T (Show Filesystem Type): Include the filesystem type (ext4, xfs, btrfs).

df -T
Filesystem     Type     1K-blocks     Used       Available  Use%  Mounted on
/dev/sda1      ext4     500000000     250000000  250000000   50%  /

Practical Use Cases

Check storage on a media server:

df -h

Spot filesystems nearing capacity. A 98% full disk will silently break Plex transcoding and Sonarr imports:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       500G  490G   10G  98% /

Verify external drives or network shares are mounted:

df -h /media/usb

If the line doesn’t appear, the mount failed.

Tips

Always use -h. The default output is unreadable.

Check before big writes. Before you rip a Blu-ray to disk or pull down a 50GB Linux ISO, run df -h and confirm you have room.

Confirm mounts after reboot. Use df to verify external drives and NFS shares came back up correctly. Half the time a “missing files” panic is actually a dropped mount.

Why It Matters

A full disk is one of the most common reasons services break on a media server. Plex can’t write metadata. Sonarr can’t import. Backups silently fail. df is a five-second check that saves hours of debugging.

In Conclusion

That’s the toolkit. Ten commands. Learn these and you can navigate a Linux box, manage files, set permissions, control ownership, and keep an eye on disk space. Which covers most of what running a media server actually requires.

You’re not going to memorize the flags from a blog post. Open a terminal. Make some folders. Move them. Delete the wrong one. Recover. That’s how this sticks. The best way to learn Linux is to break a test box and fix it.

When you’re ready for the next step, start chaining these commands together with pipes and writing small shell scripts. That’s where Linux stops being a list of commands and starts feeling like a tool you actually own.

Don’t stop at ten. But start here.

Was this useful?

Last updated on May 20, 2026 06:56 MDT