Linux commands and shortcuts


a) ls

The ls command lists the contents of a directory.The default is the current directory. You may think it is a simple command command that has very little usage.But you are wrong. There are many options for ls command.
ls -l for a detailed (long) listing
ls -F to display file type information (for more on file types and the permissions).

b) cp

Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
cp copies the contents of file1 to file2 or it copies all files to directory:

cp file1 file2
cp file1 … fileN dir

Note: A symbolic link is a special file that points to another file or directory, which is called the target. Once created, a symbolic link can be used in place of the target file name.

Follow Symbolic links means if we copy a directory that has a shortcut or symbolic link, then if we don’t specify -L, then the symbolic links won’t be updated as per the new location.

c) mv

mv renames file1 to file2. In the second form, it moves all files to the directory:
mv file1 file2
mv file1 … fileN dir

d) touch

The touch command creates a file. If the file already exists, touch does not change it, but it does update the timestamp.
touch fileName

e) rm

To delete (remove) a file, use rm. After you remov e a file, it’s gone. Do not expect to be able to “undelete”anything.
rm file

f) echo

The echo command prints its arguments to the standard output:
echo Hello there.

Directory Commands

a) cd

The cd command changes the shell’s current working directory to a given directory.If you omit dir, the shell returns to your home directory.
cd dir

b) mkdir

The mkdir command creates a new directory.
mkdir dir

c) rmdir

The rmdir command removes the directory.
rmdir dir


The shell is capable of matching simple patterns with files in the current working directory.

a) *

The simplest of these is the star character (*), which means match any number of arbitrary characters.
echo *
Prints a list of files in the current directory.
echo at*
Matches all files starting with at;
echo *at
Matches files that end with at.
echo *at*
Matches any files that contains at.

b) ?

Match exactly one arbitrary character.
echo b?at
Matches boat and brat.

Intermediate Commands

a) grep

prints the lines from a file or input stream that match an expression.
grep Hello /etc/test.txt
Print the lines in the file /etc/test.txt that contain the text Hello
Hello /etc/*
To check on every file in /etc that contains root, you could use this


CONTROL-D on a line by itself stops the current standard input entry (and often terminates a program).

CONTROL-C terminates a program regardless of its input or output.

CONTROL-Z stops a program, but doesn’t terminate it.

Suffering from Knowledge Quest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store