id (Linux command)

On April 20, 2009, in linux, linux commands, by mahesh
0


id – print real and effective UIDs and GIDs

Summery
id command is one of the basic unix commands, and it servers a very simple purpose of confirming the identity of a specified Unix user.

Simplest way to use the id command
All you do is just type id in your command line prompt, and it then gets back to you with confirmations of your own user id, group id, and a list of other groups you’re a member of:

ubuntu$ id
uid=1000(greys) gid=113(admin) groups=33(www-data),113(admin)

Share
Tagged with:
 

dirname (Linux command)

On April 20, 2009, in linux, linux commands, by mahesh
0


dirname – extract the directory name from a full path

Summary
dirname is a very simple but useful Unix command which is used mostly in shell scripting. Taking a full path to a file as a parameter, it then stips the filename off and returns you just the directory name.
How to use dirname command
This is how dirname is invoked

ubuntu$ dirname etcnetworkif-down.dpostfix etcnetworkif-down.d

dirname in shell scripting
The obvious use of dirname command is shown below. This script, based on the full path to a file, prints the parent directory name and a list of all the files in this directory

#!binbash
FILE=$1
DIR=`dirname $FILE`
FILES=`ls $DIR`

echo Filename specified $FILE
echo Parent directory $DIR

for f in $FILES; do
echo – $f
done

Share
Tagged with: