
Linux (CentOS 7) cheat sheet
This is mostly a cheat sheet for myself that and it would be updated frequently.
Find packages
# yum list | grep ldapServices
systemctl [stop|start|restart|status] servicenameChange firewalld with iptables
systemctl stop firewalld
systemctl mask firewalld
yum install iptables-services
systemctl enable iptables
systemctl start iptablesEdit iptables
# vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport [PORT_NUMBER_HERE] -j ACCEPT…or edit firewalld
firewall-cmd --zone=public --add-port=[PORT_NUMBER_HERE]/tcp --permanentStart/stop/restart Apache
systemctl stop httpd.service
systemctl start httpd.service
systemctl restart httpd.serviceCheck for running process
ps aux | grep [httpd|memcached|etc...]Search for file
# find /search/path -iname *.confView files and logs
Browse a file
# more /path/to/fileShow last entry of a file
# tail /path/to/file -n 100(use -n parameter for number of last rows)
Auto update entry from ex. log-file (use -f parameter)
# tail -f /var/log/httpd/error_logSELinux
Turn on/off SELinux
# setenforce [0|1]Turn on/off SELinux config
# setsebool -P httpd_can_network_connect_db=1List all possible (or search) SELinux config parameters
# getsebool -a [| grep httpd]Set webserver permissions for file upload with SELinux and user-groups
Edit SELinux
# setsebool –P allow_httpd_anon_write=1# chcon -R -t public_content_rw_t /var/www/Add new group
# groupadd www-dataChange group permissions on folder
# chgrp -R www-data /var/www/Add user to group
# usermod apache --append --groups www-dataView users in group
# grep 'www-data' /etc/group
www-data:x:1000:apache,rootEdit a file
#vi /path/to/filePush «a» to edit file
ESC + «:wq» for write and quit or just «:q» to quit.

Kommentarer
Laster kommentarer …