Skip to main content

Posts

Showing posts from January, 2007

Linux: Create New User Account

Creating a user account is a two step process. 1. Create a user account. prompt> useradd user-name 2. set a password for the new account. prompt>passwd user-name This will create a user with a home directory /home/ user-name and default shell set to bash.

Setting Clock

The clock can be set manually and using NTP service. 1. Manually: [root@server /root]# date 012621362007 Fri Jan 26 21:36:26 PST 2007 [root@server /root]# hwclock --utc --systohc [root@server /root]# 2. Using NTP service: Add the time server to /etc/ntp.conf and to /etc/ntp/step-tickers: /etc/ntp.conf: server 192.168.0.1 server 192.168.0.2 /etc/ntp/step-tickers 192.168.0.1 192.168.0.2 Then make sure that ntp will start at boot time: chkconfig --level 2345 ntpd on chkconfig --list ntpd And start the service: service ntpd start

Postgres Commands

To create a database; createdb [db-name] To get a psql prompt; psql [db-name] To export table data; pg_dump --data-only --table=table-name db-name > file-name Following commands can be executed at psql prompt. list all databases in postgres; \l list all tables in a database; \d execute a sql script; \i [sql-script]

Search and Replace String

A string consisting of one or more words can be replaced as follows. >cat file the black cat was chased by the brown dog >sed -e 's/black/white/g' file the white cat was chased by the brown dog A pattern can also be used for search string. For example following will replace entire string starting with 2007 until = symbol in a text. sed -e 's/^2007.*=/replacestring/' file