Linux

Linux Useful Command List

When you are developer, You are using Linux command on daily basis. Sometimes, you have face to find out some different Linux command with so many other resources. Here, I will provide you all useful command list for Linux.

You may also like this :

How to Install PHPMyadmin :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo apt-get update
sudo apt-get install phpmyadmin

[/dm_code_snippet]

How to Restart Apache2 Server :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo service apache2 restart

[/dm_code_snippet]

How to Start Apache2 Server :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo service apache2 start

[/dm_code_snippet]

How to Stop Apache2 Server :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo service apache2 stop

[/dm_code_snippet]

How to Check Apache2 Status :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo service apache2 status

[/dm_code_snippet]

How to Check PHP version :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

php -v

[/dm_code_snippet]

How to Install PHP 7.4 :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.4

[/dm_code_snippet]

You can set install any PHP version by PHP version instead of php7.4

How to Install useful PHP Extensions :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo apt-get install php7.4-gd php7.4-mcrypt php7.4-curl php7.4-intl php7.4-xsl php7.4-mbstring php7.4-openssl php7.4-zip php7.4-soap php7.4-bcmath php7.4-cli php7.4-json php7.4-mysql php7.4-xml

[/dm_code_snippet]

Check Current Directory Path :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

pwd

[/dm_code_snippet]

Move File into Folder :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

mv test.php temp/

[/dm_code_snippet]

Here, test.php is file which will be move into temp folder.

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

mv test/ temp/

[/dm_code_snippet]

Here, test is folder which will be move into temp folder.

Copy File into Folder :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

cp -R test/time.php test1/temp.php

[/dm_code_snippet]

Here, time.php file will be copy on test1/temp.php path.

Check difference of two files :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

diff test/time.php test1/time.php

[/dm_code_snippet]

Remove / Delete files from directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

rm -rf var/log/*

[/dm_code_snippet]

Find specific keyword from files :

  • From single directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -r "test" app/

[/dm_code_snippet]

  • From multiple directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -r "test" app/ vendor/

[/dm_code_snippet]

  • To show list of files of find keyword :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -rl "test" app/

[/dm_code_snippet]

  • Find word from specific type file :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -r "test" app/ --include=\*.php

[/dm_code_snippet]

This above command will find keyword from .php file only.

  • Find word from multiple type files :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -r "test" app/ --include=\*.{php,js}

[/dm_code_snippet]

This above command will find keyword from .php & .js files only.

  • Find word except specific type file :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -r "test" app/ --exclude=\*.php

[/dm_code_snippet]

This above command will find keyword except .php file.

  • Find word except multiple specific type file :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

grep -r "test" app/ --exclude=\*.{php,js}

[/dm_code_snippet]

This above command will find keyword except .php & .js files.

To Lists all the contents in the current working directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

ls -l

[/dm_code_snippet]

To Lists all the contents with hidden files in the current working directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

ls -la

[/dm_code_snippet]

To create new directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

mkdir test

[/dm_code_snippet]

To find file in specific directory :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

find m243/app/ -name env.php

[/dm_code_snippet]

This will find env.php file from m243/app/ directory.

Change PHP version from 7.2 to 7.4 :

[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

sudo a2dismod php7.2
sudo a2enmod php7.4
sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.4

[/dm_code_snippet]

That’s it !!

I hope this blog is helpful to your for Linux useful commands list. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Tagged ,