アーカイブ

2008年02月

カテゴリ:

If you would like to make an user who could not log into the system like just mail account user, use nologin instead of bash. nologin is a special command that politely refuse a login.

# grep nologin /etc/shells
/sbin/nologin

Use -s option to define the shell.

# useradd -s /sbin/nologin tomato
# su - tomato
This account is currently not available.

If you would like to change the shell of existing user, use usermod command.

# usermod -s /sbin/nologin lettuce
# su - lettuce
This account is currently not available.

アメリカで見つけたもの(JFK 編)

カテゴリ:

Trash日本人にとってゴミを捨てるときに分別するということは、特別なことではありません。ところがアメリカ(U.S.A.)の少なくともニューヨーク、ネバダ、ロサンジェルス辺りでは未だにそんな概念は導入されておりません。

ファストフードとかでゴミを捨てようにも、口は一つのみ。ほとんどの日本人であれば、ここに瓶も入れていいの?などと悩むに違いありません。いや、いいんですよ。全部そこに突っ込みましょう。

困るのが飲み残し。コーヒーとか、スモールでもすっごく多くて飲みきれないの。日本だと飲み残しを捨てる口があるところが多いけど、もちろんアメリカにはそんなものはありませんよ!だからそのままゴミ箱へ。そして回収時、底に穴が開きこぼれる…。やたらに床が汚れるのはこのせいだよね〜。

ところが先日東京に帰る飛行機に乗るために JFK (ジョン・F・ケネディ国際空港)へ行ったらびっくり。新聞を捨てようとすると3つのゴミ箱が並んでる…。

ブッシュ大統領の後を考え、アメリカも環境に優しくなりますよということなのかな。

カテゴリ:

This is traditional way of making user. At first, you need group (vegetable). Then you make a user (cabbage) with initial group vegetable. This time user cabbage has umask 022.

# groupadd vegetable
# useradd -g vegetable cabbage
# id cabbage
uid=509(cabbage) gid=505(vegetable) groups=505(vegetable)
# su - cabbage
$ umask
0022
$ touch hello
$ ls -l hello
-rw-r--r--  1 cabbage vegetable 0 Feb 25 09:01 hello

You could make a user (lettuce) without initial group. This time user automatically belongs to an initial group that has users name. The user has umask 002.

# useradd lettuce
# id lettuce
uid=510(lettuce) gid=510(lettuce) groups=510(lettuce)
# su - lettuce
$ umask
0002
$ touch hello
$ ls -l hello
-rw-rw-r--  1 lettuce lettuce 0 Feb 25 09:03 hello

カテゴリ:

If you made users, john and paul. You could make passwords automatically with the following commands. If there is no uuencode command, install it with 'yum install sharutils.'

# for user in john: paul:
> do
> echo -n $user
> head -c 6 /dev/random | uuencode -m - | sed -n '2p'
> done > /tmp/password
# cat /tmp/password
john:2S+dJ64l
paul:FwWcC2F0

chpasswd command assign passwords from the file.

# chpasswd < /tmp/password

カテゴリ:

Root user only could mount cd media.

$ mount /media/cdrom
mount: only root can mount /dev/hdc on /media/cdrom

If you add "user" option in a file /etc/fstab, user could mount it.

# vi /etc/fstab
/dev/hdb    /media/cdrom    auto    pamconsole,exec,noauto,managed,user 0 0

$ mount /media/cdrom
$ ls /media/cdrom
isolinux  squashfs.img  sysroot

カテゴリ:

You could use ISO image file without CD-R media. Use mount command with loop option.

# mount -o loop -t iso9660 ./Fedora-8-Live-i686.iso /media/cdrom
# ls /media/cdrom
GPL  isolinux  LiveOS  README

When you finish, just unmount it.

# umount /media/cdrom

カテゴリ:

シェルスクリプトを実行するとカレントシェルではなく、新たに生成される別のシェルによって実行されます。ではこれをどのように確認できるでしょうか。

まず、現在使っているシェルのPIDを表示するには"$$"を使います。

$ ps
  PID TTY          TIME CMD
24586 pts/0    00:00:00 bash
$ echo $$
24586

シェルスクリプトで確認するために下記のプログラムを作りました。1行目で標準シェル(sh)を指定しています。実行すると sh が実行していることが分かります。

$ cat show_me_shell.sh
#!/bin/sh
ps ax | grep `echo $$`
$ ./show_me_shell.sh
24647 pts/0    S+     0:00 /bin/sh ./show_me_shell.sh

1行目の指定を csh に変更すると確かに、csh で実行されることが分かります。

$ cat show_me_shell.sh
#!/bin/csh
ps ax | grep `echo $$`
$ ./show_me_shell.sh
24655 pts/0    R+     0:00 /bin/csh ./show_me_shell.sh

1行目でシェルを指定しないと sh で実行されます。下記実行例では bash が利用されていますが、これは少なくとも Red Hat 系のディストリビューションでは sh は bash へのシンボリックリンクになっているからです。

$ cat show_me_shell.sh
ps ax | grep `echo $$`
$ ./show_me_shell.sh
24672 pts/0    R+     0:00 -bash

$ ls -l /bin/sh
lrwxrwxrwx  1 root root 4 Dec 22 11:31 /bin/sh -> bash

カテゴリ:

If you do not want a bell(beep) sound when using tab key. Write "set bell-style none" to a file /etc/inputrc.

# vi /etc/inputrc
# do not bell on tab-completion
set bell-style none

カテゴリ:

If you are root user, you could send message to all users who logged in with wall command.

root user

# wall "We will have a meeting tomorrow noon."

Broadcast message from root (pts/0) (Wed Feb 6 19:06:05 2008):

We will have a meeting tomorrow noon.

user

$
Broadcast message from root (pts/0) (Wed Feb 6 19:06:05 2008):

We will have a meeting tomorrow noon.

カテゴリ:

Is enter key too far? So, use ctrl-m instead. It works same as enter key. Also, ctrl-h works same as Backspace key.

このページのトップヘ

見出し画像
×