Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Tuesday, 25 February 2014

BASIC FILE HANDLING




ls
- list files in directory; use with options
  • -l (long format)
  • -a (list . files too)
  • -r (reverse order)
  • -t (newest appears first)
  • -d (do not go beyond current directory)
  • -i (show inodes)
pg
- used to control input by pages - like the dos /p argument. pg performs the same function as the more command but has different control, as it is based on ex
Helpful keys for pg:
  • 1 (go to top)
  • $ (go to bottom)
  • h (help)
  • / (Search)
  • ? (Search back)
  • q (quit)
  • -1 (back a page)
pwd
- show present working directory. e.g.
$ pwd
/usr/live/data/epx/vss2

To change the current working directory use cd
cd
- change directory (without arguments, this is the same as $ cd $HOME or $ cd ~)
cp
- copies a file from one location to another. e.g.
$ cp /etc/hosts /etc/hosts.backup # make a backup of the hosts file
$ cp /etc/motd /tmp/jon/ # Copy file /etc/motd to directory /tmp/jon/

Options
  • -f (to force the copy to occur)
  • -r (to recursively copy a directory)
  • -p (to attempt to preserve permissions when copying)
synonym: copy
mv
- move a file from one location to another. e.g.
$ mv /tmp/jon/handycommands.txt . # move handycommands in /tmp/jon to current directory
$ mv -f vihelp vihelp.txt # Move file vihelp to vihelp.txt (forced) 

Options
  • -f (to force the move to occur)
  • -r (to recursively move a directory)
  • -p (to attempt to preserve permissions when moving)
synonym: move
.
rm
- removes a file. e.g.
$ rm /tmp/jon/*.unl # remove all *.unl files in /tmp/jon
$ rm -r /tmp/jon/usr # remove all files recursively
 Options
  • -f (to force the removal of the file)
  • -r (to recursively remove a directory)
du
Recursively lists directories and their sizes. e.g.
$ du /etc # list recursively all directories off /etc
712 /etc/objrepos
64 /etc/security/audit
536 /etc/security
104 /etc/uucp
8 /etc/vg
232 /etc/lpp/diagnostics/data
240 /etc/lpp/diagnostics
248 /etc/lpp
16 /etc/aliasesDB
16 /etc/acct
8 /etc/ncs
8 /etc/sm
8 /etc/sm.bak
4384 /etc 
The sizes displayed are in 512K blocks. To view this in 1024K blocks use the option -k
lp -d
send file to printer. e.g. $ lp -dhplas14 /etc/motd # send file /etc/motd to printer hplas14
$ lp /etc/motd # send file /etc/motd to default printer
cat
- print a file to stdout (screen). e.g.
$ cat /etc/motd # display file /etc/motd to screen
*******************************************************************************
* *
* *
* Welcome to AIX Version 4.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
******************************************************************************* 
cat is also useful for concatenating several files. e.g.
$ cat fontfile IN* > newfile # appends fontfile and all files beginning with IN to newfileThough this might seem an essentially useless command, because most unix commands always take a filename argument, it does in fact come in extremely useful at more advanced levels. Awards are given out occasionally for the most useless usage of cat. If an option of '-' is specified, cat will take its input from stdin.

No comments:

Post a Comment