Posted on March 30, 2020
Today I will teach you a very useful trick to speed up your terminal workflow. Have you ever written up a really long command only to mistakenly forget to run it as sudo?
If you have, there’s no need to rewrite the whole command or move back to the first line. All you need to do is run
What this command does is copy your last ran command and put it inside
$ dnf install htop ERROR: This command has to be run with superuser privileges (under the root user on most systems).
Now just add sudo before !! and hit enter.
$ sudo !! $ sudo dnf install htop
This command saved me so much time from retyping or moving my cursor back to the first character. I hope this new trick helped your with your workflow.
Posted on March 28, 2020
Today I will teach you how to use the
find command. The
find command is used to search and locate files in a given directory. I will show you how to use the command in its most basic form.
The syntax command is:
$ find <location> -name <searchpattern>
You will run into “Permission denied” if you don’t have the proper permissions to the folder. Otherwise it will look for the given search pattern and show you all the ones it could find.
In this example I will be looking for my passwd file
$ find "/" -type f -iname "passwd"
The find command will start its search at the root “/”, recursively – meaning it will look through its sub-directories.
-type -f means it will look for a file type and I am asking it to look for the passwd file in case-insensitive mode by adding the
Output: /sys/fs/selinux/class/passwd/perms/passwd /usr/share/licenses/passwd /usr/bin/passwd
find command is a very helpful tool that you should add to your arsenal. It will make looking for files and directories fast and easy.
Posted on March 26, 2020
Today I’m going to show you how to setup a LEMP stack. LEMP stands for LINUX, NGINX, MYSQL, PHP. LEMP is a great stack to use for WordPress and various other applications. It leverages Nginx and Php-Fpm for fast processing.
- Linux knowledge ( Beginner to Intermediate)
- Linux server – we will be working on a CentOs 7 server
- Root access ( all code will be on root unless explicitly stated)
Install epel and Remi repository
Installing the epel and Remi repository will allow us to download extra packages that are needed for installing the LEMP stack. Remi repository will allow us to install the latest PHP-FPM7.3.
$ yum install epel-release $ yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Install and enable Nginx
$ yum install nginx $ systemctl start nginx.service $ systemctl enable nginx.service
Install and enable mariadb-server
$ yum install mariadb-server $ systemctl start mariadb.service $ systemctl enable mariadb.service
We are installing yum-utils so we can utilize the tool yum-config-manager. yum-config-manager will allow us to enable/disable a repo.
$ yum install yum-utils
Disable php5.3 and enable php7.3
We will then disable php5.3 and enable php7.4 to make sure we have the correct php versions.
$ yum-config-manager --disable remi-php54 $ yum-config-manager --enable remi-php73
Install php7.3 with all the necessary modules
A very long command but this will install php7.3 with all the needed modules.
$ yum -y install php php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-pdo php-pecl-apcu php-pecl-apcu-devel
Ensure correct permissions for your PHP folder
We will be changing this to user root and group nginx since they will be talking to each other.
$ chown -R root:nginx /var/lib/php
Enable and start php-fpm
$ systemctl enable php-fpm $ systemctl start php-fpm
Setting up a LEMP stack is not difficult to do. There are just a few things you have to look out for. I hope this tutorial helped you setup your LEMP stack. Please leave a comment for suggestions!