Urgent.News

What's breaking now, across thousands of outlets.

Tech

File and Directory Management in Linux

Everything in Linux is a file. Your documents are files, your programs are files, your terminal is a file, even your hardware devices are represented as files. This single idea is what makes Linux so powerful and consistent — but it also means that if you want to be productive on the command line, you must learn to manage files and directories fluently. In this guide, we'll cover the essential…

Linux is built around the concept that everything is a file, including hardware devices. This straightforward idea is what makes Linux so powerful and consistent. To be productive on the command line, one must learn to manage files and directories fluently. This guide covers the essential commands and concepts for navigating, creating, copying, moving, and deleting files, understanding the directory structure, and finding files quickly, as well as how to avoid mistakes that can destroy data.

The Linux directory structure starts at the root directory, represented by /. Here's a list of important directories:

- /home: Personal folders of normal users

- /root: Home directory of the root user

- /etc: System-wide configuration files

- /var: Variable data, such as logs, caches, and websites

- /tmp: Temporary files, often cleared on reboot

- /usr: Installed programs and their files

- /opt: Third-party or manually installed software

- /dev: Device files (disks, terminals appear here)

- /proc: Virtual files exposing kernel and process info

Linux uses forward slashes (/) as separators and paths are case-sensitive. For example, /home/Yeasin and /home/yeasin are two different paths.

Absolute paths start from / and work from anywhere, while relative paths start from your current location. Some special names that help you move around are . (current directory) and .. (parent directory). To change directories, use cd with an absolute or relative path, or navigate up or down levels using .. or cd..

To navigate the file system, use pwd to show your current location, ls to list names of files and directories, and cd to change directories. Options like -l (long format), -a (include hidden files), -h (human-readable sizes), -lt (sorted by modification time) and -R (recursive) help customize ls output. Additional commands like cd - (toggle between last two locations), pwd (print working directory), ls (list names), and cd (change directory) are useful for navigation.

To create files and directories, use touch to create an empty file, mkdir to create directories, and a combination of touch and mkdir to create both files and directories. The -p flag in mkdir is essential as it creates parent directories if they don't exist. For creating files with content, echo can be used to write text directly to a file, and cp (copy) can be used to create a copy of a file or directory.

When copying files and directories, use cp with options like -r (recursive) to copy directories, -i (interactive) to ask before overwriting existing files, and -a (archive) to preserve metadata. Beware that cp overwrites existing files silently by default, so use -i for safety.

Moving and renaming files can be done with mv, which can also move directories. Use mv with options like -i (interactive) to ask before overwriting, and -p (preserve permissions) to maintain the original permissions of the moved files.

To delete files and directories, use rm (remove) and rmdir (remove directory). rm without options deletes files permanently, so always double-check the path. Use -i (interactive) with rm to ask for confirmation before deleting. rmdir only removes empty directories, and rm -r deletes a directory and all its contents, making it a powerful but potentially dangerous command. Always be cautious with these commands, as Linux does not have a trash bin and deletion is permanent.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Building a $0 VPS on Google Cloud: DietPi, Tailscale, IPv6, and the traps I hit

I wanted a small always-on Linux box: private SSH access, no public IPv4, and a bill of exactly zero. The job is modest — a dashboard for the box itself, a couple of small scripts, an SSH endpoint I…

  • Author aimed for $0 VPS on Google Cloud with private SSH, no public IPv4, and zero-dollar bill
  • Encountered five obstacles and installer bugs delaying goal by an evening
  • Resolved issues, verified actual charges on Google Cloud Billing

BiCS FLASH memory controller wear leveling function

This is sample code for wear-leveling functionality for BiCS FLASH (3D NAND) controllers, along with automated test code using Unity.

  • Code implements wear-leveling function in BiCS FLASH controllers
  • Follows IPA ESCR C language version 3.0 and CERT C conventions
  • Automated Unity tests verify dynamic wear leveling mechanism

Four Boundaries That Decide Whether a Beautiful Render Can Ship

Whether an appearance design can actually ship comes down to something plain: can the factory make that line, does it still look good once made, and does it feel right in the hand.

  • Transition radius on surfaces must meet manufacturability standards
  • Color appearance on screen may not match real product
  • Color break line placement crucial for assembly tolerance

More from Sunday 25 October →