Linux Mastery
The Human Knowledge Project
04 — Creating & Managing Files
Why This Chapter Matters
Nearly everything you do in Linux involves files.
Programs are files.
Pictures are files.
Music is stored in files.
Configuration settings are stored in files.
Even many hardware devices appear as files.
Directories organize those files into a logical structure that allows Linux—and its users—to locate information quickly and efficiently.
The concepts introduced in this chapter will be used throughout the remainder of Linux Mastery.
1. Files and Directories
Linux systems organize information using:
- files
- directories
Directories are often called folders in graphical environments.
Nearly everything in Linux involves:
- creating
- organizing
- moving
- editing
- deleting
files and directories.
Understanding file management is one of the most fundamental Linux skills.
2. Creating Files with touch
The:
touch
command creates empty files.
Example:
touch notes.txt
Verify:
ls
You should now see:
notes.txt
Multiple files may be created at once:
touch file1 file2 file3
The touch command is also used to update file timestamps.
3. Creating Directories with mkdir
The:
mkdir
command creates directories.
Example:
mkdir projects
Verify:
ls
You should now see:
projects
To create nested directories:
mkdir -p work/linux/chapter04
The:
-p
option creates parent directories automatically if needed.
4. Copying Files with cp
The:
cp
command copies files.
Example:
cp notes.txt backup_notes.txt
This creates:
- original file
- copied file
To copy directories recursively:
cp -R projects backup_projects
The:
-R
option means recursive.
(See Appendix A — Recursion)
5. Moving and Renaming Files with mv
The:
mv
command moves or renames files.
Rename example:
mv notes.txt chapter_notes.txt
Move example:
mv chapter_notes.txt projects/
Linux uses the same command for:
- moving
- renaming
because renaming is conceptually a filesystem move operation.
6. Removing Files with rm
The:
rm
command removes files.
Example:
rm unwanted.txt
Important
- Linux normally does NOT move deleted files into a recycle bin
- removal is often immediate
To remove directories recursively:
rm -R old_projects
Use recursive deletion carefully.
Incorrect paths may destroy important files.
7. Hidden Files
Linux hides files beginning with:
.
Example:
.bashrc
.profile
These are commonly:
- configuration files
- system settings
- hidden application data
To view hidden files:
ls -a
The:
-a
option means:
- all files
including hidden files.
8. File Naming
Linux filenames are:
- case-sensitive
These are different files:
File.txt
file.txt
FILE.txt
Good naming practices:
- use lowercase
- use underscores
- avoid spaces
- use meaningful names
Recommended:
## chapter_04_notes.md
Avoid:
Stuff Final NEW reallyfinal2.txt
Good naming improves:
- organization
- readability
- scripting
- automation
9. Wildcards
Wildcards allow commands to match multiple files.
The most common wildcard is:
*
Example:
ls *.txt
This matches all files ending in:
.txt
Another example:
rm *.tmp
This removes all files ending in:
.tmp
Wildcards are extremely powerful.
Always verify wildcard commands carefully before pressing ENTER.
10. Organizing Files
Good organization is an important Linux skill.
Common organizational methods include:
- project directories
- descriptive filenames
- backups
- separate folders for scripts and documents
Example structure:
Linux_Mastery/
├── chapters/
├── appendices/
├── problem_sets/
├── solutions/
└── assets/
Well-organized filesystems improve:
- clarity
- efficiency
- backups
- collaboration
- troubleshooting
11. Practice Exercises
1.
Create an empty file:
touch practice.txt
Verify using:
ls
2.
Create a directory:
mkdir testdir
3.
Create nested directories:
mkdir -p work/linux/ch04
4.
Copy a file:
cp practice.txt backup.txt
Verify both files exist.
5.
Rename a file:
mv backup.txt renamed_backup.txt
6.
Move a file into a directory:
mv renamed_backup.txt testdir/
7.
Create a hidden file:
touch .hiddenfile
Then display hidden files:
ls -a
8.
Create several text files:
touch one.txt two.txt three.txt
List them using:
ls *.txt
9.
Delete a practice file:
rm practice.txt
Verify removal.
12. Key Ideas
Linux systems are heavily file-oriented.
Users constantly:
- create
- move
- organize
- copy
- rename
- remove
files and directories.
Mastering file management builds:
- confidence
- efficiency
- organizational skill
- command-line fluency
These operations become the foundation for nearly all advanced Linux workflows.