So a friend asked me to write a little script for him that looks up for a specific username on a system, and if it doesn’t exist, it will create it for him. pretty easy right ?
since adding a user with useradd with a password ( -p ) requires the password to be encrypted, I also included that option in the script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#!/bin/bash USER="Enter your username" if [ `whoami` != root ] then echo "Script must be executed with the root privileges" exit fi echo "Attempting to find user $USER" ; sleep 1 cat /etc/passwd | cut -d':' -f 1 | grep $USER > /dev/null if [ "$?" -eq 0 ] then echo "User $USER already exists on the system" exit else echo -n "User $USER was not found, do you want to create the user $USER? "; sleep 1 read ans case $ans in Y|y|YES|yes) echo "Creating user $USER..." pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) useradd $USER -p $pass sleep 1 && echo "...OK" ;; N|n|NO|no|q) exit ;; esac fi |
While trying to update my repository on a RHEL 5.5 system, (note: I use a local repository on a RHEL6.0 distro), I faced this error:
[Errno -3] Error performing checksum
Trying other mirror.
Error: failure: repodata/primary.xml.gz from Updates: [Errno 256] No more mirrors to try.
This error relates to the SHA module support in 5.x version
this error is fixed once you re-create the repo with the -a sha1 command
$createrepo -a sha1 .
$yum clean all
$yum repolist
and the error was gone.
First, I would like to thank all people who find my site valuable and sent me an email about their experience with it, that was very warming to see.
After receiving many emails asking for some more exam samples, I have created a new exam for RHCE.
The exam tends to cover all RHCE objectives in different ways and approaches, feel free to ask me regarding anything that is in there.
You may download the RHCE exam in pdf format from the following Link
Edit: I’m in the process of creating a video with solutions to the exam together with sound, this may take time, please be patient.
Edit 2: you can find the complete video ( 1:22 hours!) of each objective + some tips regarding the RHCE exam. in the Link below
I would like to get feed backs regarding this tutorial, if things were clear enough, I may include a similar video with the objectives I had not managed to cover in video 1.
Download (152MB RAR -> AVI)
Where I work, we have an isolated network with no internet access, and many (many) Linux servers, mostly Red Hat Enterprise, from versions 4.0 to 6.4. and Fedora.
Wouldn’t it be awesome if you could use yum inside a network without internet access?
basically what I wanted to achieve is a central server that will serve the others with packages according to their architecture and version.
I came across the CreateRepo package that creates the metadata for your ISOs and that way the servers in your network can retrieve desired packages via httpd, with a small .repo file in their /etc/yum.repos.d.
all it takes is installing httpd, mounting ISOs to a directory (neat order preferred, each ISO gets a directory and “i386″ & “x86_64″ sub directories with rpms) and running the
createrepo .
inside that directory, and that way you get the metadata files that allows others to use the correct RPMs according to the yum command..
I have also spread a script across the linux systems that automatically detects the OS and architecture and that way creates the proper .repo file for the server with the correct path to the repository of the server.
to install createrepo simply rum
yum install createrepo