Skip to content

A base where you learn basic Linux Terminal Commands and can apply them by yourself.

Notifications You must be signed in to change notification settings

SaniTheWay/LearnBase-LinuxTerminalCommands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

LearnBase-Linux Terminal Commands(LTC) 📖

Heared about Linux? or Searching for a good Handbook for terminal Commands?

🏗️This Repository still under construction. But feel free to explore and contribute 🤿

Don't forget to 🌟Star the repository, to show your Appreciation and Love. 👏

HERE's ALL.
In a programmers' life, Linux is the thing that one should know how to use it efficiently. This is a self learn tutorial for those who new to Linux terminal and want to learn how to use it effectively.

This tutorial is covering the most used(80-90%) commands.

📙Let's Start❗

1. man command

  • to get the manual of commands that what specific command actually do and how to use it.
  • Syntax: man <command_name>
  • use q key to exit from man page

2. ls command

  • list command, used to list the files.
  • Syntax: ls accepts a lot of options
    • ls
    • ls <folder_path> - to list files of a specific folder
    • ls -al

3. mkdir command

  • to create folders
  • Syntax:
    • mkdir <folder_name> - single folder
    • mkdir <folder1> <folder2> - multiple folders
    • mkdir -p <parentfolder / childfolder> - nested folders

4. cd command

  • cd means change directory. You can jump between folders using this command. -Syntax:
    • cd <folder_name/path>
    • cd .. - to back to parent folder
    • cd ../folder_name -
    • cd /<foldername> - use absolute paths, which start from the root folder /

5. pwd command

  • prints current folder path.

6. rmdir command

  • delete empty folders using this command
  • Syntax:
    • rmdir <folder_name>
    • rm -rf <folder> : To delete folders with files in them

    ❗ NOTE: this command does not ask for the confirmation from the user and immediately remove that you ask it to remove.

7. touch command

  • to create an empty file
  • Syntax: touch <file_name>
  • If the file already exists, it opens th file in write mode.

8. mv command

  • to move the file and also to rename the file
  • mv <from_folder/file> <to_folder/file>
  • mv <file1> <file2> <tofolder> - to move more than one file, make a list of file and move to folder.

9. cp command

  • to copy a file

10. open command

  • to open a file using this command
  • Syntax: open <filename>

11. find command

  • used to find files or folders matching a particular search pattern. It searches recursively.
  • file . -name <file_name> - to find the file with its name.
  • Example: to find all the files in current directory with extension .png and also print the relative path.
    • Syntax:
    • find . -name '*.png'

12. gzip command

  • to compress a file with extension .gz

  • Syntax:

    • gzip <file_name> : using this the original file will be deleted.
    • gzip -c <file_name> > <filename.gz> : using -c option specifies that the output will go to the standard output stream without affecting original file.

    or can use -k option

    gzip -k <file_name>

    • gzip <file1> <file2> : to zip mutiple files
    • 🟡gzip -r <folder_name>: to compress a folder recursively
    • 🟢gzip -d <file_name.gz> : to decompress a file

13. gunzip command

  • equivalent to gzip command, but -d option is enabled by default.
  • Syntax:
  • gunzip [option] [archive name/file name]

14. alias command

  • to create your command for your convenience.
  • Example:
    • alias ll = 'ls -al' : use ll in place of ls -al command
  • alias : (with no option) to list all alias defines

15. cat command

  • SUPER POWERFUL command
  • cat <file_name> : prints a file content
  • cat <file1> <file2> : to print multiple file content
  • cat <file1> <file2> > file3 : to concatenate the content of multiple files into a new one.
  • cat <file1> <file2> >> <file3> : to append content of multiple files into new one.
  • cat <file_name> | <another_command> : to feed a file's content as input to another command.
  • cat -s <file_name> to remove multiple empty lines.

16. less command

  • to watch the file content in an interactive UI
  • less <filename>

17. head and tail command

  • head to print first 10 lines of the file.
  • tail to print last 10 lines of the file.

18. wc command

  • helps in counting the lines, words, and characters in a file. Mostly, it is used with pipes | for counting operation.
  • It will display the number of lines, words, and bytes from the file.
  • Syntax: wc [option]... [file]...

19. grep command

grep command filters the content of a file which makes search easy. grep stands for global regular expression print.

  • helpful in day-to-day coding
  • Syntax:
    • command | grep <searchWord> : with pipes (case sensitive by default)
    • grep <search_Word> <file_name> : without pipes
    • grep -v <search_Word> <file_name> : to search for non-matching searched word.
    • grep -i <searchWord> <filename> : to filter output in a case-insensitive way.

20. sort command

  • used to sort the list items
  • sort <file_name> : by default case sensitive and alphabetic.
  • sort -r <file_name> : reverse order sort.
  • sort --ignore-case <file_name> : to sort case insensitive, use -n to sort numerically.
  • sort -u <file_name> : to remove duplicated.
  • Example : ls | sort : used with list command.

21. chmod command

  • chmod is used to make a file executable and to change the permissions granted to it in Linux
  • chmod +x <file_name> : make a file executable.
  • chmod <permission> <file_name> : a set of flags associated with each file determines who can access that file, and how they can access it.
  • Example : chmod 755 main.py | chmod +x main.py : used to make the file main.py executable.

22. locate command

  • used to locate a file in a Linux system, just like the search command in Windows.
  • useful when you don't know where a file is saved or the actual name of the file.
  • locate -i hello: -i argument with the command helps to ignore the case, will also fetch files with Hello or HELLO or heLLo etc.
  • locate -i *hello*world*: * helps you to find the files if you remember only some words of the filename, separate them with *, for ex here linux will find any filename with the words "hello" and "world" in them.

23. clear command

  • used to clear the terminal screen
  • useful when you want to declutter your terminal window
  • Syntax: clear
  • Keyboard shortcut: Ctrl + L

24. echo command

  • used to input text and display it on standard output
  • used to print files of a specific kind : echo *.svg or simply echo * to list out the files in the current directory
  • Syntax: echo <option(s)> <string(s)>
  • 💡 NOTE: The ‘-e‘ option in Linux acts as an interpretation of escaped characters that are backslashed.

  • Example: echo -e "\vMr. \vStark \vI \vdon't \vfeel \vso \vgood.": \v creates vertical tab spaces.

Don't forget to 🌟Star the repository, to show your Appreciation and Love. 👏

About

A base where you learn basic Linux Terminal Commands and can apply them by yourself.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •