Skip to main content

Command Palette

Search for a command to run...

Getting started to Linux

Published
4 min read

image.png

Why use Linux?

  1. Open source
  2. Supports almost all programming language
  3. Terminal is superior to CMD
  4. Bash scripting
  5. SSH

Terminal (or Console)

  • It is basically a text input output environment.
  • It’s job is to launch the shell

Shell

  • The shell is the Linux command line interpreter. It provides an interface between the user and the kernel and executes programs called commands. For example, if a user enters ls then the shell executes the ls command.
  • The shell can also execute other programs such as applications, scripts, and user programs.
  • Most of the shells use Bash as their programming language.
  • So, whatever we type in terminal is basically Bash scripting.

Some key points

  • Everything in any OS is just a file. All of these files have a path and they are organised in a hierarchical order.
  • Meaning of some symbols:
  • ‘/’ → Root directory
  • ‘.’ → means that it is your current directory.
  • ‘..’ → means parent directory of your current directory
  • ‘~’ → home directory
  • ‘-’ → previous directory
  • Don't get confused between ‘-’ and ‘..’ because your previous directory may be your parent directory but that is not always the case.
  • flags add more functionality to what you are doing.
  • '#' → Comment; just add ‘#’ before any text that you want to comment.
  • You may also create new files or directory using the relative path. You need not present in the directory where you want new file or directory.
  • The root directory contains all other directories, sub-directories, and files on the system. It is the top-most level of the Linux file system hierarchy.
  • The home directory can be said as a personal working space for all the users except root. There is a separate directory for every user.

Linux commands studied so far

pwd - Print working (current) directory; shows the path where you are from the root directory.

ls - Lists all the directory/files within a current working directory.

ls -a → prints all files (including hidden ones)

ls -l→ prints in long listing format

cd - This command is used to change directory.

cd FolderAbsolutePath → navigate to the folder using the absolute path; doesn't matter which directory you're in

cd FolderRelativePath → navigate to the folder using the path relative to the current directory

cd / → navigte to root directory

cd .. → navigate to parent directory of your current directory

cd ~ → navigate to home directory

cd - → navigate to previous directory

clear - shifts the text upwards, out of the viewable area (pressing Ctrl+L also does this).

touch - To create a file without any content

mkdir - To create directories

mkdir -p→A flag which enables the command to create parent directories as necessary. If the directories exist, no error is specified.

file - To determine the file type. Type may be 'directory', 'ascii' ,'pdf document', 'JPEG image data' etc.

'gedit' - gedit is a powerful general purpose text editor in Linux. It can edit multiple files at a time.

cat - cat(concatenate) command reads data from the file and gives their content as output. It helps us to create, view, concatenate files.

vi - vi is an text editor that comes inbuilt in all Linux distribution. shift+i enables you to edit the file esc get you into modify mode esc+shift+a brought you on append of the line esc+xdelete the current letter esc+dd delete the entire line shift+: let you save or quite the document w save the document q quit the document q! quit the document without warning

cp - To copy files or group of files or directory. Use -r flag to copy an entire directory to another directory

mv - To move one or more files or directories from one place to another. No need to use flag -rto move one directory to another.

rm - To remove files or directories

rm -rv directoryName → v means verbose, which usually means they output more information than the default.

To remove directory use -r flag

rmdir - To remove empty directories from the filesystem in Linux.

rmdir can only remove empty directories whereras rm -r can remove non-empty directories.

man - To display the user manual of any command.

whatis - To get a one-line manual page descriptions.

Linux shortcuts learned so far

image.png