Skip to main content

File Management & Navigation

File Management & Navigation in Ubuntu

๐Ÿงญ 1. Navigation Commands

-lahwithsize,perms #pwd#Printworking
CommandDescription
lspwd Print #current Listdirectory filespath
cd Change directory
cd /path/to/dir Go Changeto specific directory
cd current.. Go up one directory
cd ~Go to home directory
lsList files and folders
ls -lLong listing with permissions
ls -aList hidden files
ls -lhHuman-readable size in long listing

๐Ÿ“„ 2. File & Directory Management

# # # # backup.php#Copy
CommandDescription
mkdir mydirfoldername Create Createa new directory
mkdir -p /path/to/nested/folderCreate nested directories
touch file.phptxt Create newan empty file
cp file1.txt file2.txtCopy file
cp -r folder1 folder2Copy directory
mv oldname.txt newname.txtRename or move file/directory
rm file.phptxt Delete a file
rm -r folder/ Delete Deletedirectory recursively
rm -rf folder/Force delete folder recursively(use cpwith file1.phpcaution)

๐Ÿ“ฆ 3. Folder & File Sizes

CommandDescription
du -shShow total size of current directory
du -sh foldername/Show size of a specific folder
du -ahShow size of all files and subfolders
du -h --max-depth=1Show size of each folder in current dir
df -hShow disk space usage (human-readable)

๐Ÿ” 4. Search and Find Files

CommandDescription
find . -name "file.txt"Find file mvwith exact name in current folder and subfolders
find /path -type f -mtime -7Files modified in the last 7 days
find /path -type f -mtime +30Files older than 30 days
find /path -type f -name "*.log"Find all .log files
find /path -type f -mtime +30 -name "*.log"Old log files
find /path -type f -mtime +30 -deleteDelete files older than 30 days

๐Ÿ“‹ 5. Permissions and Ownership

dir/ # Move or rename
CommandDescription
chmod 755 file.phpsh Change file permissions
chown user:group file.txtChange ownership
ls -lView current permissions and ownership

๐Ÿ—ƒ๏ธ 6. File Viewing & Editing

CommandDescription
cat file.txtDisplay contents
less file.txtView file with scroll (better for large files)
head -n 10 file.txtShow first 10 lines
tail -n 10 file.txtShow last 10 lines
nano file.txtEdit file using Nano
vim file.txtEdit file using Vim (advanced)

๐Ÿงน 7. File Compression & Archiving

CommandDescription
tar -cvf archive.tar folder/Create archive
tar -xvf archive.tarExtract archive
gzip file.txtCompress file
gunzip file.txt.gzDecompress gzip file
zip -r archive.zip folder/Create zip archive
unzip archive.zipUnzip file