Post

Basic Linux File Management

Basic Linux File Management

Here is a concise guide on Basic Linux File Management, including archiving, directory and file manipulation, and file-searching tools:


πŸ“ Basic Linux File Management


1. πŸ“¦ Common Archiving Tools

ToolCommand ExampleDescription
tartar -czvf archive.tar.gz folder/Archive and compress files (gzip).
gzip / gunzipgzip file.txt / gunzip file.txt.gzCompress/decompress single files.
zip / unzipzip archive.zip file1 file2 / unzip archive.zipCreate/extract ZIP archives.
xz / unxzxz file / unxz file.xzHigh compression ratio.
7z7z a archive.7z file7-Zip format (install p7zip).

2. πŸ“‚ Making Directories

1
2
mkdir newdir               # Create a directory
mkdir -p dir/subdir        # Create nested directories

3. πŸ“„ Copy, Move, Delete Files and Directories

Copy

1
2
cp file1.txt file2.txt              # Copy a file
cp -r dir1/ dir2/                   # Copy directory recursively

Move (or Rename)

1
2
mv oldname.txt newname.txt         # Rename or move file
mv file.txt /path/to/destination/  # Move file

Delete

1
2
3
rm file.txt                        # Delete file
rm -r folder/                      # Delete directory and contents
rm -rf folder/                     # Force delete (use with caution)

4. πŸ” Finding and Locating Files

CommandDescriptionExample
findSearches files by name, size, type, etc.find /home -name "*.txt"
locateUses a database to quickly find fileslocate firefox
updatedbUpdates the locate database (needs mlocate)sudo updatedb
whereisLocates binary, source, and man pageswhereis ls
whichShows the path of a commandwhich python3
typeShows how a command is interpretedtype cd

Config file for updatedb: πŸ“„ /etc/updatedb.conf β€” Exclude specific paths from locate indexing.


This post is licensed under CC BY 4.0 by the author.