Linux File Management Commands
- mv: Move or rename files and directories
- ls: List files and subdirectories in a directory
- cp: Copy files or directories
- mkdir: Create new directories
- pwd: Display the current working directory path
- tar: Create, list, and extract archive files
- cd: Switch working directories
- chmod: Modify file or directory access permissions
Detailed Introduction to File Management Commands
Common Linux file management commands:
mv(move) command:- Used for moving or renaming files and directories
- Syntax:
mv [source] [destination] - Examples:
mv old_file.txt new_file.txt: Renamesold_file.txttonew_file.txtmv file1.txt /path/to/directory/: Movesfile1.txtinto the specified directory
ls(list) command:- Used for listing files and subdirectories in a directory
- Syntax:
ls [options] [path] - Common options:
-l: Display file information in long format-a: Show all files, including hidden ones-R: Recursively display files in subdirectories
cp(copy) command:- Used for copying files or directories
- Syntax:
cp [source] [destination] - Examples:
cp file1.txt file2.txt: Creates a copy offile1.txtasfile2.txtcp -r dir1/ dir2/: Copiesdir1and all its subdirectories and files intodir2
mkdir(make directory) command:- Used for creating new directories
- Syntax:
mkdir [options] [directory] - Common options:
-p: Create nested directories as needed
pwd(print working directory) command:- Used to display the full path of the current working directory
- Syntax:
pwd
tar(tape archive) command:- Used for creating, listing, and extracting tar archive files
- Syntax:
tar [options] [archive_name] [files_or_directories] - Common options:
c: Create an archive filex: Extract an archive filev: Verbose; display the archiving processf: Specify the name of the archive file
cd(change directory) command:- Used for switching working directories
- Syntax:
cd [directory] - Special directories:
.: Current directory..: Parent directory~: User's home directory
chmod(change mode) command:- Used for modifying file or directory access permissions
- Syntax:
chmod [options] [mode] [file_or_directory] - Permission modes:
r: Read permissionw: Write permissionx: Execute permission
- Example:
chmod 755 file.txtsets the permissions offile.txttorwxr-xr-x