Understanding  Basic Commands

Understanding Basic Commands

📚 Today was all about diving into the essentials of Linux – from understanding distributions to exploring its architecture. 🐧 The highlight🎯? Hands-on labs 👨‍💻 with AWS EC2 Ubuntu instances, bringing theory to life!

Getting Started with Most Basic Linux Commands:

  1. ls : List Directory Contents

    • This command helps you view the contents of a directory.

    • Example: ls, ls -l (to see detailed information)

  2. cd : Change Directory

    • Use this command to navigate between directories.

    • Example: cd Documents (to enter the Documents directory)

  3. mkdir : Make Directory

    • Creates a new directory.

    • Example: mkdir Projects (to create a directory named Projects)

  4. rm : Remove

    • Deletes files or directories.

    • Example: rm file.txt (to delete a file), rm -r folder (to delete a directory)

  5. pwd : Print Working Directory

    • Displays the current working directory.

    • Example: pwd (to show the current directory path)

  6. cp : Copy

    • Copies files or directories.

    • Example: cp file.txt newfile.txt (to copy file.txt to newfile.txt)

  7. mv : Move

    • Moves files or directories.

    • Example: mv file.txt Documents (to move file.txt to the Documents directory)

  8. touch : Create Empty File

    • Creates a new empty file.

    • Example: touch file.txt (to create a file named file.txt)

  9. whoami : Show Current User

    • Displays the username of the current user.

    • Example: whoami

  10. echo : Print Text

    • Displays text or variables to the terminal.

    • Example: echo "Hello, World!"

  11. history : Command History

    • Shows a list of previously executed commands.

    • Example: history

  12. sudo : Superuser Do

    • Executes a command with superuser privileges.

    • Example: sudo apt-get update

  13. cat : Concatenate Files

    • Displays the contents of a file.

    • Example: cat file.txt

  14. vim : Text Editor

    • Opens the Vim text editor to create or edit files.

    • Example: vim file.txt

  15. clear : Clear the Terminal

    • Clears the terminal screen.

    • Example: clear

  1. grep command in Linux

The grep command is used to find a specific string in a series of outputs. For example, if you want to find a string in a file, you can use the syntax: <Any command with output> | grep “<string to find> “

  1. wget command in Linux

    The wget command in the Linux command line allows you to download files from the internet. It runs in the background and does not interfere with other processes.

    Here is the basic syntax: wget [option] [url]

Some Important question-

1.How do I view files in a Linux Directory?


To view files in a Linux directory, you should use the ‘ls’ command. It lists all files and directories in the current working directory. You can also use ‘ls -l’ to view detailed information about each file, including permissions, number of links, owner, group, size, and modification date.

2.What is the Command to Create a New File in Linux?


The command to create a new file in Linux is ‘touch’. For example, typing ‘touch filename.txt’ in the terminal will create an empty file named ‘filename.txt’. This command is handy for quickly creating new files without opening an editor.

3.How can I edit a file in Linux from the command line?


To edit a file in Linux from the command line, you can use text editors such as ‘nano’ or ‘vi’. For instance, typing ‘nano filename.txt’ will open the file in the Nano editor, allowing you to edit and save changes. ‘vi’ or ‘vim’ can be used similarly, though they have a different interface and command structure.

4.What is the Linux Command for changing file permissions?


The Linux command for changing file permissions is ‘chmod’. It allows you to set read, write, and execute permissions for the file owner, group, and others. For example, ‘chmod 755 filename’ sets read, write, and execute permissions for the owner, and read and execute permissions for the group and others.