SysAdmin Blog, TechTips and Reviews

An (ex) System Administrator's Blog



Archives Posts

How Do you Find and Replace Expressions in VI Editor

February 29th, 2012 by elizar

One and for all, let’s do this again.. how do you do the find and replace function of the Vi editor? I keep on coming back to Google for the syntax but at least I know that there is an ‘s’ in the beginning of the command and a ‘g’ at the end (for Global search). :)

Anyway, a little background before i copy paste the information here. I first taught myself how to use Vi during my ‘first’ job as a systems engineer in NEC TNCSi. Actually, my UNix foundation was all from NEC. Not that they train me how to be a unix admin, but I learned and taught myself how to do it. I read books that were lying around there and build samba servers, qmail and email servers and stuff until I got the ropes, the ins and outs of the UNix environment (Actually, I was using Linux – Redhat).

How Do You Find and Replace Text in Vi?

To perform a global search and replace in vi, use the search and replace command in command mode:

:%s/search_string/replacement_string/g

The % is a shortcut that tells vi to search all lines of the file for search_string and change it to replacement_string. The global ( g ) flag at the end of the command tells vi to continue searching for other occurrences of search_string . To confirm each replacement, add the confirm ( c ) flag after the global flag.

For this latest usage, i need to change the shell for all the users who are using /bin/ksh to a safeword sid shell.

remember to use the ‘slash’ character if you are filtering actually backslash.. You do not want to misinterpret the ‘/’ character by vi.

so, that’s

:%s/\/bin\/ksh/\/bin\/sid/g

Filed under Commands, Linux, Solaris, Unix having No Comments »

Archives Posts

KSH Script Basics | Special Shell Variables

April 23rd, 2010 by elizar

Just deleted tons of stale, unsused user accounts. Here are some KSH shell basics and special shell variable. I need to Google them up myself to get reminded that ‘$?’ is the output variable for script execution. That is, it’s 0 for successful execution and 1 if there is any error.

Read the rest of this entry »

Archives Posts

getfacl and setfacl – Unix Access Control (acl) Tool

March 17th, 2010 by elizar

Today’s topic is all about Access List… For Unix and Unix-like system, the usual command to set the file permission is the ‘chmod’ command. However there are instances that we need more flexibility in giving access and control for files and folders. Get it? Access and Control? In this situation, there is a file utility built in Unix called ‘getfacl‘ and ‘setfacl‘.


getfacl
is a file utility for viewing the access control list information associated with a file or directory.

For a memory aid, you can think of ‘getfacl’ as “Get File ACL“.. ACL being Access Control List.

Access control lists are extended attributes added to most major file systems in the 2.6 kernel to improve ability to control the access of files. They allow permissions to be set for individual groups and users and not just the owning user, owning group, and all other users.

setfacl is a command that allows you to set the Access Control List information for a file or directory.

Access control lists are extended attributes added to most major file systems in the 2.6 kernel to improve ability to control the access of files. They allow permissions to be set for individual groups and users and not just the owning user, owning group, and all other users.

You can read man pages for both getfacl and setfacl for more information.

getfacl and setfacl example….

Here’s an example of using the basic funtion of getfacl and setfacl

# getfacl

#setfacl

setfacl -m default:user::rwx,default:group::r-x,default:other:r-x,default:mask:rwx /u06/OneSource/datapump_dbdump

setfacl -m default:user:rcodapp1:r-x,default:group:r-x,default:other:—,default:mas:rwx /u06/OneSouce/datapump_dbdump

Archives Posts

Unlock locked user account in HP-UX

October 15th, 2009 by elizar

I know nothing about HP UX (yeah, except SAM). That’s why, just now, when there’s a request to just make a trace route from an HPUX server to another server, I have to login and do execute the command. I couldn’t log in as my user id so i logged in as root instead from the console.

I check grep’d my account the walah! It was there! I reset the password, open an ssh terminal and tried to login. unsuccessful, that’s why i knew then that it is locked.

Here’s how to unlock a locked user account in HP UX in command line.

In HP-UX 11.xx if user account is locked, you can unlock the account by running SAM. But running SAM takes some time usually 2-3 minutes on heavily loaded HP-UX servers. You can unlock the locked user account from command line by running following command:

1. Login as root or use sudo from your account, if there is no sudo installed just use su – root :

$sudo su –

*******

2. Run this command to unlock the locked HP-UX user account:

#/usr/lbin/modprpw –l –k johnm

Running modprpw will unlock the locked user account in HP-UX from command line.without running SAM

NOTE: modprpw is HP-UX command only and wouldn’t work in Solaris,AIX and any Linux servers

That info was ‘borrowed’ from here…. thanks!

Archives Posts

Send Break on SPARC Enterprise T5120 – Send Break on ILOM

October 15th, 2009 by elizar

Send Break on SPARC Enterprise T5120 – well it for the T5000 series I guess, the newer ones. Or “Sending Break onan ILOM..

“->” = ILOM
“sc>” = ALOM

.. and since this particular server has the “->” prompt we’re using the ILOM.

From ILOM to Solaris:
-> start /SP/console

From ALOM to Solaris:
sc> console

And of course.. Enter “#.” to return to ALOM / ILOM !!

Send Break on ILOM

set /HOST send_break_action=break
and then
start /SP/console

c)ontinue, s)ync, r)eset? s

bada bing! bada boom!

Archives Posts

Configure Virtual Hosting in Apache Web Server

August 19th, 2008 by elizar

When we say or mention the word Web Server, the first thing that comes to our mind is Apache, right? (if you don’t then what are you doing here reading this? :-))

Apache is the most well known open source web server there is! Open source?? Make that the most wildly used webserver on the internet, period!

It is believed (and i know they made a survey or study about it) that Apache takes 90% of all web servers in the internet. Most web hosting company, and I’ve once worked in one, use Apache.

This post will talk about how to setup Apache for Virtual Hosting

Read the rest of this entry »

Archives Posts

All About Arlo Gilbert

April 28th, 2008 by elizar

Who in heaven is Arlo Gilbert? Yep, using ‘heaven’ is perfect for describing this man for he do sometimes tries to conquer heaven. He’s into planes you see. :)

Anyway, you’re probably Googling about Arlo Gilbert as you read this post. Well, let me save you a few minutes and introduce you to Mr. Gilbert in one fast minute.

He is the following:

  • The Man is from Austin, Texas
  • Arlo Gilbert is a high school drop out… and a proud one (don’t do that boys and girls)
  • A family man! So there’s a Mrs. Gilbert and two little Arlo Gilberts (daughters)

The reason why we feature this brilliant man is that he has successfully launched online startups and been doing it for 10 years now. Remember, high school dropout and no training in marketing or any business related studies… Brilliant indeed.

What caught my attention while reading his ‘About’ page was his current project – the iCall. It’s a VOIP startup company. I was wondering if iCall was developed by Arlo Gilbert or if it uses Asterisk?

.

.

.

Tekken Philippines

Filed under Uncategorized, Unix having 14 Comments »

Archives Posts

vi Search and Replace… The Basics, Dummy’s Reference

March 13th, 2008 by elizar

Yep, this is a dummy’s reference… I keep on forgetting the syntax so I might as well put it here for my own reference… 😀

vi is the one, if not the most popular text editor available for a System Administrator on a UNIX and UNIX-like machines.

It has two modes, command and editor mode.

Here are some syntax in using the Search and Replace in ‘vi’.

Search:

The most basic and most easily remembered command for searching is vi is slash or ‘/’ followed by the character being searched. That’s for forward searching. For backward, vi use ‘?’ followed by the string being searched.

To go to the next occurrance of the string being searched, vi use ‘n’ command. Doesn’t matter if your searching forward (from up, down) or backward, from down to top.

Example:

(you have to be in command mode… press ESC first)

/search_string

?search_string

Search and Replace

For search and replace, use the syntax

:%s/original/replaced/g

Make sense?
Any command that begins with a “:” is called a line mode command and performs its duty on the line the cursor is currently on.

The above syntax serves my purpose now… If I want to replace text in certain ranges.. syntax can be found here

Filed under Linux, Solaris, Tips, Unix having 2 Comments »

Archives Posts

About the /proc and -xdev parameter for ‘find’

November 20th, 2007 by elizar

/proc is a pseudo-filesystem used to access process information from the kernel. It doesn’t use any storage space and uses little memory. On Linux, you can sometimes make modifications to the running kernel by modifying “files” in /proc.

If / is full, run a command similar to the following to sort all files in the / file system by size:

find / -xdev -ls | sort -n -k 7

“-xdev” limits the find command to the root file system.

This will only look for files found in the root and will not includes those partitions that are defined in /etc/vfstab | /etc/fstab file, those listed when `df -k` is executed:

/dev/md/dsk/d0 2058319 1016097 980473 51% /
/dev/md/dsk/d3 2058319 1801793 194777 91% /var
etc .. etc..

Thanks Brandon!

Brandon H. – Senior UNIX Systems Engineer for an application services provider in Minneapolis, MN.

Filed under Commands, Tips, Unix having No Comments »

Archives Posts

Difference Between NFS, DNS, NIS+, and NIS

November 11th, 2007 by elizar

NFS, DNS, NIS and NIS+… that’s a lot of acronyms!

Network File System

NFS is Sun’s Networked File System, and by now, more or less, the de facto method of sharing file systems between computers.

Domain Name Service

DNS is the Domain Name Service, which is the way information about hostnames and addresses are shared across the Intenet.

Network Information (Name) Service

NIS stands for Network Information Name Service. It was original called Yellow Pages, which is why many of the commands for NIS start with yp (such as ypbind, ypcat, etc.) NIS was developed by Sun, and is, like NFS, more or less the default way of sharing system information between UNIX machines.

NIS+

NIS+ is Sun’s re-implementation of NIS. It attempts to address some of the problems with NIS, but the implementers of NIS+ have made a series of bad choices in the design of NIS+, so it has seen only limited usage compared to the other types of services you asked about.

Filed under Unix having 1 Comment »

« Previous Entries

I was here...