I have had a post about linux commands. as I had promised, here I am going to progress it.
First of all I have forgotten a very useful command.
23. locate sth: to search something
Example: [root@testserver opt]# locate test
Result:
/usr/share/tcl8.4/tcltest2.2/testresults.tcl
/usr/share/vim/vim70/syntax/colortest.vim
/usr/share/vim/vim70/syntax/hitest.vim
/var/lib/mysql/test
...
- -b: match only the base name of path names
- -c: only print number of found entries
- -i: ignore case distinctions when matching patterns
- ... . use --help to see all of switches.
Result:3310
also you can use "| grep sth" to limit it more:
Example: [root@testserver opt]# locate test | grep tomcat
Result:
/opt/apache-tomcat-6.0.18/webapps/ROOT/html/testing/myportlet/menu.jsp
/opt/apache-tomcat-6.0.18/webapps/ROOT/html/testing/myportlet/view.jsp
/opt/apache-tomcat-6.0.18/webapps/ROOT/html/testing/myportlet/images/menu-btm.pn
...
Set a variable for all user
Sometimes we need to set a variable for all users. for example:CATALINA_HOME=/opts/tomcat
or
JAVA_OPTS=-Xms256m -Xmx512m -XX:MaxPermSize=128m
To do it, you need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:
vi /etc/profile
write your export command at the end of the opened file
- then save and quit it. :wq! + Enter
- this variable will be created whenever anyone log in. you can see it via echo command.
...
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done
export JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=128m"
Yum automated software installation and update
Yum is the easiest way to keep all programs up to date. It downloads and installs the latest version of a program. A single command can update all software installed, including third-party software, security updates and operating system. It can do the updating automatically in the night. here we install yum and make it do all the above.
Yum is similar to, but better than apt, apt4rpm, windows update, up2date, yast and many other package managers I have ever seen.
Yum works in a safe, standardized way. It uses rpm (Red Hat package manager) for installing programs. Authenticity of packages is checked with strong gpg encryption. Package repositories are just folders on a web server.
We will install yum, then choose trusted packagers and start installing programs. We will also see some yum tips.
Install yum
Red Hat has rpm package manager installed by default. We use rpm to install yum.
First download yum then go to the folder where you downloaded yum. If you can see the file with ls, you are on the right place. you can also use locate command to find its path. Then write this command:
rpm -Uvh yum*.noarch.rpm
In the command above, rpm -Uvh means installing just like rpm -i you may have used allready. -Uvh just displays some extra info and erases old version of program if necessary. You can rpm -q yum to see if yum is installed. It should tell you the version number of yum.
Exampe: [root@testserver opt]# rpm -q yum
Result: yum-2.0.3-0.fdr.1.rh90
Add trusted packagers to your keyring
In yum, it really does not matter if enemy takes over the internet and fakes to be some website offering software. All software is cryptographically checked before installation (if you have set gpgcheck=1 in yum.conf. this is the configuration file of yum. you can locate to find this file). To install some software, we must tell yum who we trust.
rpm --import /usr/share/doc/yum-*/Fedora-GPG-KEY
rpm --import /usr/share/doc/yum-*/RPM-GPG-KEY
Start installing software
yum install lynx
Because it is your first run, it first downloads headers that contain information about what is available. This can take as long as 20 minutes, but it only needs to be done once. Yum prints the names of headers it downloads
Gathering header information file(s) from server(s)
Server: Fedora Linux / stable for Red Hat Linux 9 (i386)
Server: Fedora Linux / testing for Red Hat Linux 9 (i386)
Server: Red Hat Linux 9 (i386)
Server: Red Hat Linux 9 (i386) updates
Finding updated packages
Downloading needed headers
getting /var/cache/yum/fedora-stable/headers/leafnode-0-1.9.43-0.fdr.1.rh90.i386.hdr
getting /var/cache/yum/fedora-stable/headers/libzvt-devel-0-2.0.1-0.fdr.5.rh90.i386.hdr
getting /var/cache/yum/fedora-stable/headers/mhash-devel-0-0.8.18-0.fdr.1.rh90.i386.hdr
[..]
Resolving dependencies
Dependencies resolved
I will do the following:
[install: lynx 0-2.8.5-7.1.i386]
Is this ok [y/N]: y
If any additional programs, dependencies, are needed, yum will ask if you want to install those too. For example, lynx needs perl-CGI, so if we don't have that installed yet, yum installs it.
Calculating available disk space - this could take a bit
lynx 100 % done 1/1
Installed: lynx 0-2.8.5-7.1.i386
Transaction(s) Complete
Now try lynx. If you can run lynx (the text mode web browser), you have succeeded. Congratulations, you have now installed the state of the art package manager yum.
Yum tips
Here there are other useful switches with yum:
- yum list "*ssh*": To list packages that have "ssh" in the name
- chkconfig yum on: To make yum update all programs every night
- yum remove up2date: To remove a program, dependencies handled
- yum -y install curl: -y answers "yes" to all questions
all rights reserved by Mostafa Rastgar and Programmer Assistant weblog
No comments:
Post a Comment