Linux Guide: My Learnings As A Beginner

Linux Guide: My Learnings As A Beginner

What Is Linux Shell?

An interface to interact with the Linux OS. A CLI interface that takes in inputs to produce outputs.

Some Common Commands And What They Do:

echo Hello

returns Hello

echo -n hello

-n removes the new line created after returning hello


how long system has been running after reboot

cd My_Directory

Navigates to / changes to the directory mentioned which in this case is My_Directory


Returns/shows the directory we’re currently in

mkdir new_directory

Creates a new directory. In this case, it created a new directory named – new_directory

mkdir -p hello/this/is/new_directory

This created subdirectories or in other language, all directories at once specified provided they don’t exist.

-p option helps with that.

cd .. OR cd

changes directory to home directory no matter where we currently are

Command Types In Linux

Internal: echo, cd, pwd, set

External: mv, date, uptime, cp


Use the type command to see if the command is internal or external.

Absolute & Relative Path In Linux

An absolute path is specified the location by displaying all the directories that lead to the directory we want to navigate to. Starting from the root directory.

The root directory can be denoted by a slash /

Here we want to navigate to an example:

cd hello/this/is/an/example

We can write the same thing above as

cd example (this is called relative path)

Pushd & Popd Commands

pushd commands remembers/saves the current directory (pwd) and then changes to the directory specified in the command.

when you want to return to the ORIGIN directory, use popd command and you’re back to the last directory you used pushd on. Doesn’t matter how many directories you navigated to post the pushd command.

Mv Commands

```is for move.



mv /home/source_directory /home/filler/destination_directory

here /home/source_directory is the source directory which we want to move
/home/filler/destination_directory is the directory where we want to move


mv source_directory destination_directory

Make sure you’re in the main/home directory and then you can exclude writing that.

**Using MV For Renaming
The files/directory should be in the same directory

mv xbox/games/farcri xbox/games/farcry

## Copying Files In Linux

We use the cp command.

cp xbox/games/farcry/cheats.txt xbox/games/GTA

here, xbox/games/farcry/cheats.txt is the source and cheats.txt is the file we want to move to the directory GTA

## Removing Files In Linux

We use the rm command.

rm xbox/games/farcy/cheats.txt

## Copying/Removing Directories In Linux

We always have to use the -r option along with the commands we usually use for Files.

R in -r means recursive operation.


rm -r xbox/games/farcry

## Reading The Content Of A File In Linux

We use the cat command

cat xbox/games/farcy/cheats.txt

## Changing The Content Of A File In Linux

Use cat >

Here, > means redirection.

cat > xbox/games/farcy/cheats.txt

*Now you’ll type whatever you want and then press CONTROL + D to save it.

## Creating A New File In Linux

Use the command touch for this.

touch xbox/games/halo/cheats.txt ```

This will create an empty file.

More And Less Command In Linux

More command helps view large files by displaying one page at a time in a scrollable format.

Less command displays lesser files hence making it easier to read the deets of a file.

Space key: scrolls 1 screen worth data at one time

Enter key: scrolls one line at a time

b key: scrolls backwards, 1 screen worth data at a time

/ key: search for something in the file

up arrow key: scrolls up one line at a time

down arrow key: scrolls down one line at a time

/ key: search for something in the file, for example, text

LS (Long List)

ls lists all content in a directory

ls whatever_directory

ls -l provides even more details. provides details like access modes, ownership, last accessed time

ls -l whatever_directory

check hidden files with ls -a command.

you will notice two files represented by . and ..

. means current working directory

.. means directory in the file system which is before current directory

List all files on the order they were modified

ls – lt (newest to oldest)

ls -ltr (oldest to newest)

Getting Help From Command Line Itself

whatis xyz

whatis command gives a brief description of what a command does

Use -h or –help option

Displays options and usecases of command

apropos xyz

apropos command searches for a keyword in system

Shell Types In Linux

  • Bourne Shell (sh)
  • C Shell (csh / tcsh)
  • Korn Shell (ksh)
  • Z Shell (zsh)
  • Bourne Again Shell (bash)