restarting/stopping/starting a service
On any init.d based linux distro you can restart a service with the following…
/etc/init.d/serviceName restart
You may replace ‘restart’ with ’stop’ or ’start’ (and in some cases ’status’).
Forcefully stopping a service
killall processName
Killing on instance of a service
kill pid
The pid can be gathered by either top or ps
Disabling/adding/listing services
chkconfig –list
displays all the services and if they are set to run in different runlevels
use the –del daemonName to remove a service or –add daemonName to add one
chkconfig [–level <levels>] <name> <on|off|reset>
eg. chkconfig –level 3 httpd on
This will set the httpd to ON on run level 3.
setting a program to run at startup
Add a line executing the command at the end of /etc/rc.local
File Manipulation
Editing Text Files
vi is by far the best text editor but has a learning curve to it. If you want simplicity use nano
display a text file from the command line
cat filename
or
more filename
Display the last few lines of a text file
tail filename
or you can display the last 50 lines of a file with…
tail -50 filename
or you can display lines as they are written to a file (or follow) with the following: (UBER useful for log files)
tail -f filename
copy a file
cp filename destination
move a file
mv filename destination
delete a file
rm -f filename : removes the file. -f makes it so it doesn’t ask you if you are sure
Displaying the differences between two files
diff file1 file2
Installing crap
On redhat derived systems (RedHat, Fedora, CentOS, Rocks, Mandrake, etc) yum is your package manager.
yum install appname : installs the application from the remote yum repository
yum search appname : does a search on the repository for a given program
yum remove appname : uninstalls an app
use ‘man yum’ for a complete list
Archives
tar.gz or .tgz is the most common compression found in the linux world. that is tared (Tape ARchive) and gziped. Sometimes called “tar balls”.
tar -xzf file.tgz : will X’trackt a tar/gzip file.
tar -czf myfile.tgz someDir : will create a tar and gziped archive of the given directory
gunzip : un gzips a file
unzip : unzips a .zip file