Terminal commands relared to files in the Ubuntu

 🔍 Viewing and Navigating Files

CommandDescription
lsList files and directories in the current directory
ls -lLong listing (with permissions, size, date, etc.)
ls -aShow hidden files (those starting with .)
cd [directory]Change directory
pwdPrint current working directory
treeView directory structure in tree form (may need sudo apt install tree)

📁 Creating and Managing Files

CommandDescription
touch filenameCreate a new empty file
nano filenameEdit a file using nano text editor
cat filenameView file contents
more filename / less filenameScroll through file contents
cp file1 file2Copy a file
mv oldname newnameRename or move a file
rm filenameDelete a file
rm -i filenameDelete with confirmation
rm -f filenameForce delete without confirmation

📂 Working with Directories

CommandDescription
mkdir directory_nameCreate a directory
mkdir -p path/to/directoryCreate nested directories
rmdir directory_nameRemove empty directory
rm -r directory_nameRemove directory and contents recursively
cd ..Go up one directory level

🔒 Permissions and Ownership

CommandDescription
chmod [permissions] filenameChange file permissions
chmod +x filenameMake a script executable
chown user:group filenameChange file owner and group

📦 Searching and Finding Files

CommandDescription
find . -name "filename"Find a file by name in current dir recursively
locate filenameQuickly find a file (needs mlocate database)
grep "text" filenameSearch for text in a file
grep -r "text" directory/Search recursively for text in directory

📄 File Compression and Archiving

CommandDescription
tar -cvf archive.tar file1 file2Create a tar archive
tar -xvf archive.tarExtract a tar archive
zip archive.zip file1 file2Create a zip file
unzip archive.zipExtract a zip file

Comments

Popular posts from this blog

Top Laravel Security Best Practices: How to Secure Your Web Application 🚀

Restoring Your Data in Xampp: A Step-by-Step Guide

Implement a real-time, interactive map