Posts Tagged ‘linux commands’

Basic Linux Commands Made Easy Part2

July 9th, 2017 No comments

In the previous post, we discussed some Linux commands and we saw how to show files, traverse directories, make them, and much more. Now, that was just the first level of the basic Linux commands. Let’s take one more step and see more of the basic Linux commands that you will use.

We talked about the ls command in the previous post and we’ve discussed only 2 parameters. Let’s dig deeper and see more parameters that can make you more powerful.

ls R  to recursively list all files in a directory

The -R parameter will traverse deeply till it finishes all directories. As you can see, for large directory structures, this can become quite a large output listing.

ls -R command

ls r  Reverses the sorting order for the displayed files and directories.

ls -r- command

ls S  Sorts the output by file size.

ls -lS command

ls t  Sorts the output by file modification time.

ls -lt command

Filtering Output

ls l myfile?

A question mark is used to represent one character.

ls l myprob*

An asterisk is used to represent zero or more characters.

The question mark and asterisk are called wild characters.

ls wild character

Creating Files

touch test1

The touch command is used to create an empty file. You can use the touch command to change the access and modification times of an existing file without changing the file contents.

touch command

If you use it against an existing file, it will change the access time, if the file doesn’t exist, it will create it.

In order to change the modification time,  just type it with -t followed by the time with the following format YYYYMMDDHHMM

touch t 202012011200 test1

touch existed file

Linking files

We know from the previous post that cp command is used to copy files.

What about creating a shortcut to that file in a different place. In Linux, this is called linking files.

There are two different types of file links in Linux:

  • hard link
  • symbolic, or soft link

cp l file1 file2

Hard Links

The hard link creates a separate file which contains information about the original file and where it is located.

Keep in mind that you can only create a hard link between files on the same physical drive, you can’t create hard links between files under separate mount points.

If you need to create links on a different physical drive, you’ll have to create a soft link instead.

cp hardlink

Symbolic Links

The -s parameter creates a symbolic or soft link:

cp s file1 file2

cp softlink

Here we should mention also another command that makes links other than cp which is ln command, you can create hard and soft links with it like this:

ln myfile myfile2

This command creates a hard link.

ln command

ln s myfile myfile2

This command creates a soft link.

ln softlink

Viewing the file type

file myfile

Determines the kind of the file.

file command

Viewing parts of a file

We know also from the previous post the cat command and the less command. Another important command that you will use a lot in your daily work which is the tail command.

The tail command

This command displays the last 10 lines of a file.

-n parameter to specify the number of lines

-f parameter to stay on the file and continue to watch the last lines you specified like monitoring, and this is very important when looking at log files.

tail command

The head command

Like tail command, but this command displays the first 10 rows of a file with the same tail command parameters.

head command

Running Processes

ps aux

This command is to see the currently running processes.

ps aux

top command shows the running processes.

-c parameter to show the command path that is running.

top command

kill command to kill a running process.

To kill a process

pkill processName

kill command

type xkill and press Enter to kill any nonresponsive window.

xkill command


df command shows the disk free space.

df h

-h for human readable value

df command

That was some of the basic Linux Commands. I hope you enjoy it. Keep coming back.

This post was originally published on Like Geeks site here.

Categories: LikeGeeks, Linux Tags:

Main Linux Commands Easy Guide

June 21st, 2017 No comments

In the previous post, we discussed how to install Linux, now we are going to talk about the most powerful features in Linux which is Linux commands or shell commands.

For the whole documentation of Linux Commands, you can check Linux Documentation.

If you will use Linux, you should know that the power of Linux resides in its shell and the commands that you can use on that shell which gives you the ultimate power.

I’m going to talk about the main Linux commands with their main parameters that you might use daily.

ls Command

List the content of the current directory.



to list the content as a detailed list.


Display all files includes hidden files.

You can combine parameters like this:

linux ls command

cd Command

Change directory from the current directory to another one.

Will go to home directory

linux cd command

cp Command

Copy the source to target.



Interactive mode means wait for the confirmation if there are files on the target will be overwritten.


Recursive copy means include subdirectories if they found.


linux cp command

mv Command

Move the source to target and remove the source.



Interactive mode means wait for the confirmation if there are files on the target will be overwritten.


linux mv command

rm Command

Delete file or directory and you must use –r in case you want to delete a directory.



Recursive delete means delete all subdirectories if found.


Interactive means wait till confirmation

linux rm command

mkdir Command

Create new directory

linux mkdir command

rmdir Command

Delete a directory

linux rmdir command

chown Command

Change the ownership of a file or directory to the user you specify.



Capital R here means to change ownership of all subdirectories if found and you must use this parameter if you use the command against a directory.

linux chown command

chmod Command

Change the permission of a file or directory.


The mode which is divided into 3 parts, ownergroup, and others means what will be the permissions for these modes, and you must specify them.

Every one of the 3 modes takes a permission.

The permission is one of the followings:

Read =4

Write = 2

Execute =1

Every permission represented by a number as shown and you can combine permissions.


That means set permission for the file named myfile as follows:

owner: set it to 7 which means 4+2+1 means read+write+execute.

group: set it to 5 which means 4+1 means read+execute.

other: set it to 5 which means 4+1 means read+execute.

Note: execute for a folder permission means opening it.

linux chmod command

locate Command

To find a file in your system, the locate command will search the system for the pattern you provide.

linux locate command

updatedb Command

updates the database used by the locate command.

date Command

Simply prints today’s date. Just type date on the shell.

tar Command

Combines several files into archive and compression if you want.



Create new archive.


Compress the resulting archive using gzip package.


Compress the resulting archive using bzip2 package.


Verbose mode show the processed files.


Write the output to a file and not to screen.


Unpack files from archive.


linux tar command create

This command will pack and compress all files in folder myfiles to a compressed archive named myfiles.tar.gz.

linux tar command extract

This command will decompress the archive.

cat Command

Display file content to screen without limits.


linux cat command

less Command

Displays file content with scroll screen so you can navigate between pages using PgUp, PgDn, Home, and End.

grep Command

Searches for a string in the specified files and displays which line contains the matched string.



Recursive search inside subdirectories if found.


Insensitive search and ignore case.


Display file name, not the text lines.



linux grep command

passwd Command

Used to change your user password.

linux passwd command

du Command

Calculates the disk usage of a file or a directory.



Display human readable form.


Summarize the output total size.


linux du command

reboot Command

Reboot the system immediately. Just type reboot.

halt Command

Shuts down the system, but make sure to close all of your files to avoid data loss.

That was just some of the main Linux commands.

Notice that, if you forget any command parameters,  just type the command with – -help as a parameter and it will list the used parameters so you don’t have to remember all those parameters at the beginning.

cat help

to be continued.

This post was originally published on Like Geeks site here.

Categories: LikeGeeks, Linux Tags: