Linux for DevOps Basic Command Part -1

Linux for DevOps Basic Command Part -1

File and Directory Management Commands

Here is an overview of common file and directory management commands in Ubuntu Linux, along with explanations. These commands will help you manage files, directories


1. ls - List Files

Usage: ls [options] [directory]

Explanation: Lists the files and directories in the current directory.

Options:

ls -l: Displays detailed file information (permissions, owner, size, etc.).

ls -a: Shows all files, including hidden files (files starting with a dot).

Example:

bash
ls -l  /home/user/Document        


2. cd - Change Directory

  • Usage: cd [directory]
  • Explanation: Changes the current working directory to the specified directory.

Example:

bash
cd  /home/user/Documents        

3. pwd - Print Working Directory

  • Usage: pwd
  • Explanation: Displays the full path of the current directory.

Example:

bash
pwd        

4. mkdir - Make Directory

  • Usage: mkdir [options] directory_name
  • Explanation: Creates a new directory.
  • Options:

mkdir -p: Creates parent directories if they do not exist.

Example:

bash
mkdir  new_folder 
mkdir  -p  parent_folder/child_folder        

5. rmdir - Remove Directory

  • Usage: rmdir directory_name
  • Explanation: Removes an empty directory.

Example:

bash
rmdir empty_folder        




6. rm - Remove Files or Directories

  • Usage: rm [options] file_name
  • Explanation: Removes files or directories.
  • Options:

rm -r: Removes a directory and its contents recursively.

rm -f: Forces the removal without asking for confirmation.

Example:

bash
rm myfile.txt 
rm -rf my_directory        

7. mv - Move or Rename Files

  • Usage: mv [source] [destination]
  • Explanation: Moves or renames files or directories.

Example:

bash
mv  old_name.txt  new_name.txt 
mv file.txt  /home/user/Documents/        


8. cp - Copy Files or Directories

  • Usage: cp [options] source destination
  • Explanation: Copies files or directories.
  • Options:

cp -r: Copies directories recursively.

Example:

bash
cp  myfile.txt  /home/user/Backup/ 
cp  -r  folder/  /home/user/Backup/        

9. touch - Create an Empty File

  • Usage: touch file_name
  • Explanation: Creates a new empty file or updates the timestamp of an existing file.

Example:

bash
touch newfile.txt        

10. chmod - Change File Permissions

  • Usage: chmod [permissions] file_name
  • Explanation: Changes the permissions of a file or directory. Use numeric or symbolic values.

Example:

bash
chmod 755  script.sh      # Owner can read, write, execute; group and others can read, execute 
chmod   u+x script.sh              # Adds execute permission for the owner        

11. chown - Change File Owner

  • Usage: chown [owner] file_name
  • Explanation: Changes the ownership of a file or directory.

Example:

bash
chown  user:user file.txt        

12. find - Search for Files and Directories

  • Usage: find [directory] [options]
  • Explanation: Searches for files or directories based on a given condition.

Example:

bash
find   /home/user -name "*.txt"        

13. df - Disk Free Space

  • Usage: df [options]
  • Explanation: Displays the available disk space on file systems.
  • Options:

df -h: Shows disk space in human-readable format (KB, MB, GB).

Example:

bash
df -h        

14. du - Disk Usage

  • Usage: du [options] [directory]
  • Explanation: Shows the disk usage of files and directories.
  • Options:

du -h: Shows sizes in human-readable format.

du - sh: Displays the total size of a directory.

Example:

bash
du  -sh  /home/user/Documents        


These are some of the fundamental file and directory management commands that you can use in Ubuntu or other Linux-based systems.


#DevOps #Linux #Automation #SysAdmin #CloudComputing #CI/CD #Kubernetes #Docker #Ansible #Terraform #Jenkins #Scripting #InfrastructureAsCode #Monitoring #AWS #AzureDevOps #Security #GitOps #Containers #DevSecOps #Linux #DevOps #SysAdmin #FileManagement #Ubuntu #Automation #Scripting #ShellScripting #Bash #TextEditing #LinuxCommands #ConfigurationManagement











































Abdelkarim Abadi

Mechatronics | Automation & Robotics Enthusiast | 3rd-year Student

2 个月

Excellent! Thanks for sharing????

回复
Mintu Hasan

Network Engineer || Ethical Hacker ||CCNA ||Windows Server || Linux Server REHL || System administration || ISDB-BISEW IT Scholarship

2 个月

Very helpful ????????????

回复
Mohinur Rahman

Spring Boot || Angular || Oracle

2 个月

Very informative

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了