Day 2 Task: Basics linux command

Day 2 Task: Basics linux command

Β·

4 min read

🐧 LINUX COMMAND πŸ’»

  • πŸ“‚ Navigate through Directories:

    • cd: Change directory, to move to a different folder.

    • ls: List files and directories in the current folder.

  • πŸ“„ Work with Files:

    • touch: Create an empty file.

    • cp: Copy files or directories.

    • mv: Move or rename files or directories.

    • rm: Remove files or directories.

  • πŸ—ƒοΈ Manage Directories:

    • mkdir: Create a new directory.

    • rmdir: Remove an empty directory.

  • πŸ” Search for Information:

    • grep: Search for a specific pattern in files.

    • find: Search for files and directories based on various criteria.

  • πŸ“Š Check System Information:

    • uname: Display system information.

    • df: Show disk space usage.

    • free: Display memory usage.

  • βš™οΈ Manage Processes:

    • ps: List running processes.

    • kill: Terminate a running process.

  • πŸ“ Compress and Archive Files:

    • tar: Create or extract tar archives.

    • gzip: Compress files using gzip compression.

  • πŸ”„ Control System Services:

    • systemctl: Control system services, like starting or stopping them.
  • πŸš€ Network-related Commands:

    • ping: Check network connectivity to a specific host.

    • ifconfig or ip: Display network interface information.

  • 🚧 Administrative Tasks:

    • sudo: Execute commands with administrative privileges.

πŸ“‚Check your present working directoryπŸ“‚

  • To verify the present working directory on a computer means to identify the folder or directory you are presently in. It makes it easier for you to Know where you are in the file system, which can be helpful when you wish to navigate to a particular spot or conduct operations on files.

πŸ” Follow these steps to check your present working directory:

  1. πŸ–₯️ Open a Terminal or Command Prompt:
  • On Windows, you can open the Command Prompt by searching for "Command Prompt" in the Start menu.

  • On macOS, open the Terminal from the Utilities folder in the Applications folder.

  • On Linux, you can usually find the Terminal in the Accessories or System Tools menu.

  1. πŸ•΅οΈβ€β™‚οΈ Use the "pwd" Command:
  • In the Terminal or Command Prompt, type the command "pwd" (which stands for "Print Working Directory") and press Enter.
  1. πŸ“‹ View Your Present Working Directory:
  • After running the "pwd" command, you will see the full path of the current directory displayed on the screen. Example Output:/home/sriparthu/day-2

πŸ’ΌπŸ’» Here's what it means:

  • /: The forward slashes separate folders in the file path.

  • home: The top-level folder where user-specific directories are located.

  • sriparthu: Your actual username on the computer (e.g., "nsparthu" or "As per your username").

  • day-2: The specific folder you are currently in (in this example, the "Documents" folder).

Knowing your current working directory can make it easier for you to access files and directories, run programs, and navigate the file system! πŸš€πŸ”πŸ“‚

πŸ“‚List all the files or directories including hidden filesπŸ”

πŸ” Follow these steps to list all files and directories, including hidden ones:

  1. πŸ•΅οΈβ€β™‚οΈ Use the ls Command with the -a Option:
  • In the Terminal or Command Prompt, type the command ls -a and press Enter.
  1. πŸ“‹ View the List of Files and Directories:
  • After running the ls -a command, you will see a list of all files and directories, including the hidden ones, displayed on the screen. Example Output:. .. .new-file.txt

πŸ’ΌπŸ’» Here's what it means:

  • .: Represents the current directory.

  • ..: Represents the parent directory.

  • .new_file.txt: A hidden file that starts with a dot (.).

Listing hidden files might be helpful for gaining access to configuration files or files that are generally hidden to prevent unintentional loss or modification. However, if you are unfamiliar with the function of these files, proceed with caution when working with them. πŸš€πŸ”πŸ“‚

πŸ“‚Create a nested directory A/B/C/D/E 🏠

  • A nested directory is one that has been created by nesting other directories inside of one another to build a hierarchy. Here, we're going to build a directory structure with five levels: A, B, C, D, and E. (FOLDER IN FOLDER)

πŸ” Follow these steps to create the nested directory:

  • You can create a nested directory structure in Linux using the mkdir command along with the -p flag to create parent directories as needed.

Here's an example command to create the nested directory structure A/B/C/D/E:

mkdir -p A/B/C/D/E

This command will create the directories A, B, C, D, and E within each other, ensuring that the entire nested structure exists. The -p flag tells mkdir to create parent directories as required, even if they don't already exist.


Happy Learning

Thanks For Reading! :)

-SriParthuπŸ’πŸ’₯

Β