Linux / UNIX File and Directory Management Commands

Introduction
Linux and UNIX are powerful, open-source operating systems widely used in servers, cloud platforms, development environments, and academic institutions. File and directory management is a fundamental skill for working efficiently in UNIX/Linux systems. These operating systems rely heavily on the command-line interface, making it essential for users to understand various commands for managing files, directories, permissions, and processes. This article explains important file, directory, permission, and utility commands with syntax, examples, and theoretical explanations.
Directory Structure in UNIX/Linux
UNIX/Linux follows a hierarchical directory structure starting from the root directory (/). All files and directories are organized under this root. Each directory can contain files as well as subdirectories, allowing logical data organization. Important system directories include /bin (essential commands), /etc (configuration files), /home (user directories), and /var (variable data such as logs).
Basic Directory Commands
| mkdir – Create a new directory Syntax: mkdir directory_name Example: mkdir test Description: Used to create directories to organize files. |
ls – List files and directories Syntax: ls [options] Example: ls -l Description: Displays directory contents with optional detailed information. |
cd – Change directory Syntax: cd directory_name Example: cd /home/user Description: Allows navigation between directories. |
pwd – Display present working directory Syntax: pwd Description: Shows the full path of the current directory. |
File Creation and Viewing Commands
| touch – Create empty files or update timestamps Syntax: touch filename Example: touch file1.txt Description: Commonly used to create placeholder files. |
cat – Create, display, or merge files Syntax: cat filename Example: cat file1.txt Description: Used to view file contents quickly. |
tee – Write output to file and terminal Syntax: command | tee filename Example: echo “Hello” | tee file.txt Description: Useful in pipelines and logging. |
File and Directory Management Commands
| cp – Copy files or directories Syntax: cp source destination Example: cp a.txt b.txt Description: Copies files from one location to another. |
mv – Move or rename files Syntax: mv old new Example: mv file1.txt file2.txt Description: Used for renaming or relocating files. |
rm – Remove files or directories Syntax: rm filename Example: rm test.txt Description: Deletes files permanently. |
rmdir – Remove empty directories Syntax: rmdir directory_name Description: Removes directories that contain no files. |
Permission and Ownership Commands
UNIX/Linux uses a permission-based security model.
| chmod – Change file permissions Syntax: chmod permissions filename Example: chmod 755 script.sh Description: Controls read, write, and execute permissions. |
chown – Change file owner Syntax: chown user filename Description: Assigns ownership to a user. |
chgrp – Change group ownership Syntax: chgrp group filename Description: Assigns group ownership. |
Search and Disk Usage Commands
| find – Search for files and directories Example: find /home -name file.txt |
grep – Search text patterns Example: grep “error” log.txt |
df – Display disk space usage Example: df -h |
du – Display directory size Example: du -sh folder |
Utility Commands
| echo – Display messages Example: echo “UNIX Commands” |
wc – Word, line, and character count Example: wc file.txt |
head – Display first lines of file Example: head file.txt |
tail – Display last lines of file Example: tail file.txt |
vi Editor
vi is a powerful text editor used for editing files in UNIX/Linux systems.
Syntax: vi filename
It operates in command mode, insert mode, and colon mode, allowing efficient text editing without a graphical interface.
Conclusion
This article covers essential and extra UNIX/Linux operating system commands related to file and directory management, permissions, searching, and utilities. Mastering these commands helps users work efficiently, securely, and confidently in UNIX/Linux environments and forms a strong foundation for advanced system administration.
Author : Kishor Kumar
LinkedIn : https://www.linkedin.com/in/kishor-kumar-900159329
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates.
KTExperts is always active on social media platforms.
Facebook : https://www.facebook.com/ktexperts
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform
Note: Please test scripts in Non Prod before trying in Production.


