Opening Hours

Mon - Sat: 7AM - 7PM

In Unix programming, file management is an essential aspect of working with the file system. Here are some commonly used file management commands in Unix:

  1. ls: List files and directories in the current directory.Example:
    ls -l # Long format, showing detailed information
    ls -a # Show hidden files
    ls -lh # Long format with human-readable file sizes
  2. cd: Change the current working directory.Example:
    cd /path/to/directory
    cd .. # Move to the parent directory
    cd # Change to the user's home directory
  3. pwd: Print the current working directory.Example:
  4. mkdir: Create a new directory.Example:
    mkdir new_directory
  5. rmdir: Remove an empty directory.Example:
    rmdir empty_directory
  6. cp: Copy files or directories.Example:
    cp file.txt /path/to/destination/
    cp -r directory /path/to/destination/ # Recursively copy directories
  7. mv: Move or rename files or directories.Example:
    mv file.txt new_file.txt
    mv directory /path/to/destination/ # Move directory to another location
    mv old_name new_name # Rename a file or directory
  8. rm: Remove files or directories.Example:
    rm file.txt
    rm -r directory # Recursively remove directories and their contents
  9. touch: Create an empty file or update the timestamp of an existing file.Example:
    touch new_file.txt
  10. cat: Concatenate and display the contents of a file.Example:
    cat file.txt
  11. more / less: Display the contents of a file one screen at a time.Example:
    more file.txt
    less file.txt
  12. head / tail: Display the first or last few lines of a file.Example:
    head file.txt
    tail -n 10 file.txt # Show the last 10 lines of the file
  13. chmod: Change file permissions.Example:
    chmod +x # Add execute permission to a script
    chmod 644 file.txt # Set specific permissions (rw-r--r--)
  14. chown: Change file ownership.Example:
    chown user:group file.txt



Recommended Articles