These commands are for CentOS 7.
Apache error log
$ less /var/log/httpd/error_log
Nignx error log
$ less /var/log/nginx/error.log
See mysql/mariadb error log
$ less /var/log/mysql/error.log
$ less /var/log/mysql/error.log
php-fpm error log
$
less /var/log/php-fpm/www-error.log
And google the error message. Usually google knows how to deal with the error.
Edit Apache conf file
$ sudo vi /etc/httpd/conf/httpd.conf
Edit Nignx conf file
$ sudo vi /etc/nginx/conf.d/default.conf
Permission
Check permission
$ ls -la
Change permission
$ sudo chmod 755 /var/www/html/index.py
Make something executable
$ sudo chmod +x /var/www/html/index.py
Change owner
$ sudo chown apache:apache /var/www/html/index.py
SELinux
When SELinux is enabled, make something executable (recursively).
$ sudo chcon -R -t httpd_sys_script_exec_t /var/www/html/index.py
When SELinux is enabled, make something readable (recursively).
$ sudo chcon -R -t httpd_sys_content_t /var/www/html/index.py
Check context
$ ls -Z
Disable SELinux.
$ sudo setenforce 0
Enable SELinux.
$ sudo setenforce 1
Check SELinux status (enabled or disabled).
$ sudo getenforce
Returned value: Enforcing (enabled) / Permissive (disabled)
Directories
Change currecnt directory
$ cd /vagrant
Go up one directory
$ cd ..
Go down to a directory
$ cd ./some_folder
Check current directory
$ pwd
Symbolic link
Symbolic link is a kind of file that is similar to the shortcut in Windows. Create a symbolic link "python3.6" that refers to /bin/python_three:
$ sudo ln -s /bin/python3.6 /bin/python_three
Or:
$ sudo ln -s /usr/bin/python3.6 /usr/bin/python_three
And python_three can be used as another name of python3.6 command.
Create symbolic link from apache's html to vagrant's shared folder. This can be used to sync the two folders (Both folders "html" and "vagrant" always have same contents inside after running these commands):
$ sudo rm -rf /var/www/html
$ sudo ln -fs /vagrant /var/www/html
Delete a symbolic link
$ sudo unlink /bin/python_three
Or just remove the link like removing a file
$ sudo rm -f /bin/python_three
Network
Check status of ports and established connections
$ sudo netstat -an
Search port 80 from the result
$ sudo netstat -an | grep 80
("| grep something") can be used to search for any text data. For example,
$ sudo yum list
shows a list of packages. But if you use grep
$ sudo yum list | grep php
Stop the processes that are using port 3306 and 8080.
$ sudo kill -9 $(sudo lsof -t -i:3306)
$ sudo kill -9 $(sudo lsof -t -i:8080)
For Ubuntu
Upgrade Ubuntu major version.
$ sudo do-release-upgrade
MariaDB/Postgresql
Run SQL from sql file.
// postgresql
$ psql -U [postgres username] -d [db name] -a -f [path to the .sql file]
// mariadb
$
sudo mysql -u [your user name of mariaDB] -p[your password of mariaDB]
$ source [path to the .sql file]