Okay, I have to admit that I’m not a Linux guy at all. When it comes to Linux, all I can say is Google. So here’s my little commands compilation to help me remember those linux commands and other *nix related stuff.
CentOS
System
- #system-config-services
To open the system config services, similar to the services.msc of Windows. I think a graphical terminal is needed (like X, GNome, or KDE) - the running version.
#uname -a - Find out about the Linux version .
#cat /etc/*-release - Startup scripts with chkconfig
- #chkconfig –list | grep named
To check if a specific service (in this case, bind) is loaded during the startup process. - #chkconfig –del named, or #chkconfig –add named
Delete or add a new executation script (named) to the startup process. The script must be located in /etc/init.d/script_name with executable permission set. - #chkconfig –level 3 named
Make sure that named is loaded while the OS is running in level 3 (terminal). Use level 5 is for graphical mode (running under GNOME or KDE) - Monitoring log messages
Most applications while running write out log messages. These messages will help debug a particular application (such as BIND or heartbeat) or discover a login attack. - #tail -f /var/log/messages
To monitor the most current messages in the system log - Miscellaneous
- #yum install package_name
To install a new package, for example, use #yum install subversion mod_dav to install subversion and mod_dav - #find / | grep filename
This will search the entire / dir for the file name. Very handy to locate a known file (apache config file, for example) - #rpm -q –all | grep [package name]
Look for a particular package
Ex: rpm-q –al | grep php to look for any php-related packages - #rpm -e [package name]
Remove a particular package. The package name has to be exact - wget -rv ftp://user:password@domain.com/path/to/folder
Download all contents of the “folder” on the domain.com using the ftp account user/password. -r is for recursive and the v is for “verbose” - MC shortcut (I’m a big fan of MC, btw)
- CTRL + S will search the directory in the current pane for that string name.
- CTRL + J will automatically “paste” the file/ directory under the cursor to the command line.
- MySQL
- Change a user’s password using the command line:
- #mysql -u root -p
Login to the mysql client. Password will be prompted - mysql> use mysql;
Switch to the mysql database, where the users information are stored - mysql> UPDATE user SET password=PASSWORD(”new_password”) WHERE User=’username’;
- mysql> flush privileges;
Web Servers (Apache)
- #/etc/init.d/httpd restart or server httpd restart
To restart apache - /etc/httpd/conf and /etc/httpd/conf.d are the 2 folders that contain the Apache conf files.
Networking
- #ifconfig -a
to see the list of all network devices - #dhclient eth0
to turn on the DHCP client for device eth0 - #dhclient -r eth0
this will release the DHCP lease for device eth0. - /etc/sysconfig/network-scripts
this is the folder where all the config files for networking devices are stored. You can assign static IP to the device here. For details, see the NetAdminTools.com’s article - #/etc/init.d/network restart
to restart the network services so that the new config files are picked up - /etc/hosts
this is the file where the hostname of the machine is stored - #route
this will show the currently used gateways - #route add default gw 192.168.2.1 eth0
this will add the default gateway 192.168.2.1 to the eth0 device. The gw can also be set in the /etc/sysconfig/network-scripts/dev_name_config_file.cfg (with dev_name_config_file can be lo or eth0) - /etc/resolv.conf
this file allows to define the name servers
Plesk
- /var/www/vhosts/
Here are the DocumentRoot under Plesks. Domains are stored as separated folders - /var/www/vhosts/[domain_name]/conf/
Domain-specific configuration file is stored here. Similarly Subdomains config files are stored in
/var/www/vhosts/[domain_name]/[sub_domain_name]/conf/vhost.conf
Consult the PWSoft Plesk Docs page for more info