DEV Community

Shreyas Vithalkar
Shreyas Vithalkar

Posted on

πŸš€ Day 2 of My 90-Day DevOps Challenge: Exploring Linux Basics

Today, I started my journey into Linux, an essential skill for any DevOps engineer. From exploring the Linux file system to mastering basic commands and the Vim editor, here’s what I learned. 🐧

Image description

πŸ“‚ Key Linux Directories

  1. /usr/home: Holds user-specific files, configurations, and personal data.
  2. /bin: Contains essential system commands like ls, cp, and mv.
  3. /etc: Stores configuration files for the system and applications.
  4. /tmp: Temporary files created by processes or applications, usually cleared on reboot.
  5. /var: Contains variable data like logs, caches, and queues. Logs are often helpful for debugging.
  6. /lib: Shared libraries and modules used by executables in /bin and /sbin.

πŸ› οΈ Basic Linux Commands

File and Directory Operations

  • Create a file: Used to create an empty file or update the timestamp of an existing file.
touch file.txt
Enter fullscreen mode Exit fullscreen mode

Creates an empty file named file.txt.

  • Copy a file: The cp command is used to copy files and directories.
cp source.txt destination.txt
Enter fullscreen mode Exit fullscreen mode

Copies source.txt to destination.txt.

cp -r source_directory/ destination_directory/
Enter fullscreen mode Exit fullscreen mode

Copies the entire contents of source_directory into destination_directory. The -r option ensures all files and subdirectories are copied.

  • Move or rename a file: The mv command is used to move or rename files.
mv file.txt /path/to/destination/
Enter fullscreen mode Exit fullscreen mode

Moves file.txt to the specified destination directory.

mv oldname.txt newname.txt
Enter fullscreen mode Exit fullscreen mode

Renames oldname.txt to newname.txt.

  • Display file contents: The cat command is used to display the contents of a file.
cat file.txt
Enter fullscreen mode Exit fullscreen mode

Displays the contents of file.txt.

  • List files in a directory: The ls command lists the contents of a directory.
ls
Enter fullscreen mode Exit fullscreen mode

Lists all files and directories in the current directory.

ls -l
Enter fullscreen mode Exit fullscreen mode

Displays detailed information like permissions, ownership, and file size.

ls -a
Enter fullscreen mode Exit fullscreen mode

Lists all files, including hidden ones (those starting with .).

  • Make/Create Directories: Used to create directories.
mkdir new_directory
Enter fullscreen mode Exit fullscreen mode

Creates a single directory.

mkdir -p parent_directory/child_directory
Enter fullscreen mode Exit fullscreen mode

The -p option creates parent directories if they don’t exist.

  • Remove Files or Directories: The rm command is used to delete files or directories.
rm file.txt
Enter fullscreen mode Exit fullscreen mode

Removes a file.

rm -r directory_name
Enter fullscreen mode Exit fullscreen mode

The -r option ensures recursive deletion of all contents in the directory.

By understanding these commands with their options (-r, -a, etc.), you can efficiently manage files and directories in Linux systems.

✨ Key Takeaway

Today’s learning covered the foundational Linux commands to create, copy, move, and view files, as well as navigate directories. Mastering these commands is a critical first step toward becoming proficient in Linux, a core skill for any DevOps professional! πŸš€

Stay tuned for more amazing content πŸ˜€.

Top comments (0)