If you routinely setup Linux systems with the same user accounts, you might find it helpful to be able to add the users with a single command, without typing in the password and other info for each user like you have to do with adduser. A single-line, no-questions-ask command also lends itself well to batch scripting.
To do this you'll need to know the username, the system user id and group id (UID and GUID) and plain text password for the user you're about to add.
Start by making the crypted password hash. You can make the password hash with the following command (this is tested on Debian Linux):
mkpasswd -H md5
mkpasswd will ask you for the password:
Password:
Type in your password, hit enter and mkpasswd will show you the hash:
$1$uv.y5wtb$remRyh2SeDD9mgZ81aYuB1
Here is the full command. Put the hash mkpasswd printed in single quotes at the end of the line like this:
useradd -g 1003 -m -u 1003 -s /bin/bash johndoe -p '$1$uv.y5wtb$remByh2ShDD9mgZ81aYuB1'
The shell parameter "-s /bin/bash" is not strictly necessary but I've found it best to include it to avoid potential accidents.
Note that when using useradd like this, the groups must be preexisting. If the group doesn't already exist, add it with:
groupadd groupname
It's a good idea to clear your shell history after adding all your users this way. An easy way to clear the history is by running the following commands, one at a time:
HISTFILESIZE=1
ls
^d
(^d means Ctrl-d: hold down the control key, tap the d key, then let go of the controll key)
Showing posts with label work. Show all posts
Showing posts with label work. Show all posts
Wednesday, July 15, 2009
Sunday, July 12, 2009
Installing PINE on Debian Etch 4.0 from source or binary
The Pine email client is not included in the Debian Linux "main " repository because of licensing issues.
It is included in non-free. If you don't already have SSL installed, or, if you have the old version installed, you can just add non-free to your /etc/apt/sources.list, so that it looks (somewhat) like this:
deb http://ftp.us.debian.org/debian/ etch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ etch main contrib non-free
deb http://security.debian.org/ etch/updates main contrib non-free
deb-src http://security.debian.org/ etch/updates main contrib non-free
and then run apt-get update ; apt-get install pine.
However, I already had a newer version of libssl installed, and pine demanded the old SSL libary as a dependency before it would install. I can't downgrade on this system, so I decided to install pine from source. I tried the source from pine's home page, and it wasn't compiling, so I got the Debian pine package source with apt and told it to compile it. It worked pretty well. The command to use is:
apt-get --compile source pine
That left pine_4.64-3_i386.deb in my working directory, along with a bunch of other files. You might want to build in a temporary directory.
After the build I installed pine with:
dpkg -i pine*i386.deb
You can probably use a similar set of steps on Debian Lenny 5.0, but I haven't tried it.
You can also try the newer "alpine" package.
It is included in non-free. If you don't already have SSL installed, or, if you have the old version installed, you can just add non-free to your /etc/apt/sources.list, so that it looks (somewhat) like this:
deb http://ftp.us.debian.org/debian/ etch main contrib non-free
deb-src http://ftp.us.debian.org/debian/ etch main contrib non-free
deb http://security.debian.org/ etch/updates main contrib non-free
deb-src http://security.debian.org/ etch/updates main contrib non-free
and then run apt-get update ; apt-get install pine.
However, I already had a newer version of libssl installed, and pine demanded the old SSL libary as a dependency before it would install. I can't downgrade on this system, so I decided to install pine from source. I tried the source from pine's home page, and it wasn't compiling, so I got the Debian pine package source with apt and told it to compile it. It worked pretty well. The command to use is:
apt-get --compile source pine
That left pine_4.64-3_i386.deb in my working directory, along with a bunch of other files. You might want to build in a temporary directory.
After the build I installed pine with:
dpkg -i pine*i386.deb
You can probably use a similar set of steps on Debian Lenny 5.0, but I haven't tried it.
You can also try the newer "alpine" package.
Thursday, July 9, 2009
Emacs Example Tutorial: replace words text with a regexp
In Emacs' normal find-and-replace mode you can't replace special characters like "beginning of line" or "end of line" with anything because it treats the special characters representing end of line (^ and $, respectively) as regular characters - a literal ^ and a literal $.
If you want to replace the beginning of line or end of line with another string (and this can come in extremely handy some times) you have to use a different kind of replace: RegExp replace (regexp stands for the term regular expression, which is a phrase used to describe computer pattern matching code or directions. Think "filters"). To get Emacs into this mode type:
M-x replace-regexp
Remember, M is the meta key, which is usually equal to holding down the alt key or tapping on the escape key. So you can think of this as:
ALT x
Emacs will prompt you that it is waiting for more instructions by displaying "M-x". Then you type in:
replace-regexp
and hit enter. Emacs will now ask you "Replace regexp: " - it is waiting to know the regular expression that matches the characters you want to replace.
So let's say you have a file of information - a list of names of employees, for example. This hypothetical list contains nothing but their names. Let's say you want to add a note at the end of the line that reads "Note: give this employee a new mouse pad:."
While emacs is sitting there asking you "Replace regexp: " type in just the dollar sign and then hit enter: $
Now Emacs will ask you "Replace regexp $ with: "
You can now type in any text you want, and then hit enter - Emacs will append that text to the end of the line. Unlike the regular find-and-replace, replace-regexp does not ask you for confirmation one line at a time, it will simply apply this "replacement" to every line of the file at the end-of-line mark.
As a very cool side benefit, you can combine this with block editing mode to constrain the replacement to a fixed block of lines. For more on block editing mode and how to define a block, see this article on emacs block editing.
If you want to replace the beginning of line or end of line with another string (and this can come in extremely handy some times) you have to use a different kind of replace: RegExp replace (regexp stands for the term regular expression, which is a phrase used to describe computer pattern matching code or directions. Think "filters"). To get Emacs into this mode type:
M-x replace-regexp
Remember, M is the meta key, which is usually equal to holding down the alt key or tapping on the escape key. So you can think of this as:
ALT x
Emacs will prompt you that it is waiting for more instructions by displaying "M-x". Then you type in:
replace-regexp
and hit enter. Emacs will now ask you "Replace regexp: " - it is waiting to know the regular expression that matches the characters you want to replace.
So let's say you have a file of information - a list of names of employees, for example. This hypothetical list contains nothing but their names. Let's say you want to add a note at the end of the line that reads "Note: give this employee a new mouse pad:."
While emacs is sitting there asking you "Replace regexp: " type in just the dollar sign and then hit enter: $
Now Emacs will ask you "Replace regexp $ with: "
You can now type in any text you want, and then hit enter - Emacs will append that text to the end of the line. Unlike the regular find-and-replace, replace-regexp does not ask you for confirmation one line at a time, it will simply apply this "replacement" to every line of the file at the end-of-line mark.
As a very cool side benefit, you can combine this with block editing mode to constrain the replacement to a fixed block of lines. For more on block editing mode and how to define a block, see this article on emacs block editing.
Thursday, June 11, 2009
Emacs Example Tutorial: replace words in a file
This example shows how to search-and-replace words in a file.
First we assume you are used to searching for strings or characters in a word, if you are not, please see this article on how to use emacs to find words and letters in a file.
You can replace strings or characters (words, letters) in a file in a manner very similar to find. You type this command (remember, M is the meta key, which is usually equal to holding down the alt key or tapping on the escape key):
M %
So you can also think of this as:
Alt Shift 5
After you type that key command sequence, Emacs will ask you:
Query replace:
Then you type in the characters that you are looking for that you want to replace and hit enter. Then Emacs will ask you:
Query replace [search-string-here] with:
Now you type in the characters you want to insert in place of the old word and again hit enter. Emacs will find the first instance of the "search" string (the word you want to replace), it will highlight that occurrence and then ask you:
Query replacing [search-string-here] with [replacement-string-here]: (? for help)
If you want that occurrence to be replaced, you just tap the y key for "yes". Emacs will automatically move on to the next occurrence of the string you searched for and ask again:
Query replacing [search-string-here] with [replacement-string-here]: (? for help)
If you want to skip any particular occurrence, just tap the n key for "no". Emacs will continue find and replace until you reach the bottom of the file.
First we assume you are used to searching for strings or characters in a word, if you are not, please see this article on how to use emacs to find words and letters in a file.
You can replace strings or characters (words, letters) in a file in a manner very similar to find. You type this command (remember, M is the meta key, which is usually equal to holding down the alt key or tapping on the escape key):
M %
So you can also think of this as:
Alt Shift 5
After you type that key command sequence, Emacs will ask you:
Query replace:
Then you type in the characters that you are looking for that you want to replace and hit enter. Then Emacs will ask you:
Query replace [search-string-here] with:
Now you type in the characters you want to insert in place of the old word and again hit enter. Emacs will find the first instance of the "search" string (the word you want to replace), it will highlight that occurrence and then ask you:
Query replacing [search-string-here] with [replacement-string-here]: (? for help)
If you want that occurrence to be replaced, you just tap the y key for "yes". Emacs will automatically move on to the next occurrence of the string you searched for and ask again:
Query replacing [search-string-here] with [replacement-string-here]: (? for help)
If you want to skip any particular occurrence, just tap the n key for "no". Emacs will continue find and replace until you reach the bottom of the file.
Tuesday, October 7, 2008
Linux on a Dell Vostro 1710 laptop - don't try it [yet]
Recently my company needed a new laptop for one of our employees. After my great success with installing SuSE Linux on a Dell Vostro 1700 laptop, we decided to buy a Dell Vostro 1710, hoping that it would have better, newer hardware and still work with SuSE.
Wrong.
For this first time in my entire 11+ years of using Linux, the installer could not use the trackpad or even the keyboard. Yes, you read that right. I was able to complete the install with an external USB mouse and keyboard, but after the install finished and I rebooted the system without the peripherals (hoping that it was only the installer having trouble), the laptop's built-in keyboard and mouse still wouldn't work. I can't image what Dell has done to prevent detection/use of a simple keyboard.
I never bothered to try the other hardware (camera, etc) - we sent the 1710 back and bought a refurbished 1700.
I strongly suggest nobody buy a 1710 until at least another round of distros has been released this coming winter or spring. It was openSuSE 11.0 that I tried on the 1710 - perhaps 11.1 will work with the 1710, but I'm sure I won't be ordering another one to try it on.
Wrong.
For this first time in my entire 11+ years of using Linux, the installer could not use the trackpad or even the keyboard. Yes, you read that right. I was able to complete the install with an external USB mouse and keyboard, but after the install finished and I rebooted the system without the peripherals (hoping that it was only the installer having trouble), the laptop's built-in keyboard and mouse still wouldn't work. I can't image what Dell has done to prevent detection/use of a simple keyboard.
I never bothered to try the other hardware (camera, etc) - we sent the 1710 back and bought a refurbished 1700.
I strongly suggest nobody buy a 1710 until at least another round of distros has been released this coming winter or spring. It was openSuSE 11.0 that I tried on the 1710 - perhaps 11.1 will work with the 1710, but I'm sure I won't be ordering another one to try it on.
Monday, November 5, 2007
Social networking
Today I'm trying out a Technorati Profile to see if any of these things actually help. Still got lots to learn! :-)
Thursday, February 15, 2007
Intro
I'm a system administrator for a small Central Texas IT Company, Cedar Creek Software. We specialize in custom programming projects, usually involving relational database programming for website backend engines.
I am also a technical consultant for a variety of businesses and organizations, including my father-in-law's stained glass studio, Stanton Glass Studio.
I specialize in small LAN and heterogeneous network administration, mostly using Linux and Mac OS X.
I am also a technical consultant for a variety of businesses and organizations, including my father-in-law's stained glass studio, Stanton Glass Studio.
I specialize in small LAN and heterogeneous network administration, mostly using Linux and Mac OS X.
Subscribe to:
Posts (Atom)