$ type sendmail
sendmail is /usr/sbin/sendmail
This command is merely an alias for 'whence -v'
Use option: -v for verbose mode
$ chmod 666 handycommands
changes the permissions (seen by ls -l) of the file handycommands to -rw-rw-rw-
r = 4, w = 2, x = 1. In the above example if we wanted read and write permission for a particular file then we would use r + w = 6. If we then wanted to have the file have read-write permissions for User, Group and All, then we would have permissions of 666. Therefore the command to change is that above.
$ chmod 711 a.out
Changes permissions to: -rwx--x--x
Additional explanation of file permissions and user/group/all meaning are given in the description of ls -l
You may specify chmod differently - by expressing it in terms of + and - variables. For example
$ chmod u+s /usr/bin/su
will modify the "sticky bit" on su, which allows it to gain the same access on the file as the owner of it. What it means is "add s permission to user". So a file that started off with permissions of "-rwxr-xr-x" will change to "rwsr-xr-x" when the above command is executed. You may use "u" for owner permissions, "g" for group permissions and "a" for all.
chown informix *.dat # change all files ending .dat to be owned by informix
chgrp sys /.netrc # change file /.netrc to be owned by the group sys
or find
$ mkdir /tmp/jon/ # create directory called /tmp/jon/
$ find . -name "system.log" -print # will find all files (with full path names) called system.log - Wildcards are allowed, e.g.
$ find /tmp -name "sl.*" -atime +0 -print # will print out all files in /tmp/ that start sl. and which haven't been accessed for a day. Helpful for finding lost files, or finding stuff in enormous directories. Other useful options include:
- -atime +
- finds files that haven't been accessed for 1+days also, ctime (creation time) and mtime (modify time) - -prune - stay in current directory - don't look in dirs off the directory specified in path names - e.g.
$ find /tmp -user "compgnc" -prune -print # will find all files in /tmp which user compgnc owns and will not search lower directories (e.g. /tmp/usr) - -size +
- finds files that are bigger than - -exec rm {} \; - remove all files found...dangerous command - e.g.
$ find /tmp -name "sl.*" -atime +0 -prune -print -exec rm {} \; # will remove all files in /tmp starting 'sl.' that haven't been accessed for a day. Spacing of this command is important! Most exec commands are possible:
$ find /usr2/calltest -name "*.4gl" -print -exec grep "CHECK" {} \; | pg - -ok - like exec only it prompts for confirmation after each occurence. e.g.
$ find /tmp/disk7 -name "*" -print -ok doswrite -a {} {} \; # Please note that you MUST end any exec or ok option with an escaped semicolon (\;). - -user
- finds all files owned by - -group
- finds all files with a group of
$ ln -s /usr/uniplex/compgnc /u/compgnc/uni # would create a link called 'uni' in the directory /u/compgnc. From then on, typing cd uni would cd to /usr/uniplex/compgnc. You can also give two files the same name. e.g.
$ ln make.e_enquiry makefile # would link the two files so that they are identical, and when you change one, you change the other. You may also create a symbolic link to a host(!). Instead of typing 'rlogin hpserver' every time, by typing
$ ln -s /usr/bin/rsh hpserver # will create a link so that whenever you type 'hpserver' it will execute a remote shell on the machine.
Option -f forces the link to occur
$ head -45 label1.out | lp -dlocal1
$ tail -f vlink.log # follow end of vlink.log file as it is created.
- -l (lines)
- -c (chars)
- -w (words)
$ split -5000 CALLS1 # will split file CALLS1 into smaller files of 5000 lines each called xaa, xab, xac, etc.
$ cat handycommands | tr "\t" " " # will take the file handycommands and translate all tabs into spaces. Useful when messing about with awk or you need to convert some input (e.g. that from tty) to a unique filename that does not contain special characters. e.g.
$ tty | tr "/" "." # produces for example .dev.pts.7
Used for debugging shells, seeing error messages which flash off the screen too quickly, etc.
$ cut -d "|" -f1,2,3 active.unl # will take the file active.unl which is delimited by pipe symbols and print the first 3 fields options:
- -d
- -f
$ cut -c8-28 "barcode.txt" # would cut columns 8 to 28 out of the barcode.txt file.
Name:
Employee Number:and another file with the lines:
Fred Bloggs
E666then by doing:
$ paste file1 file2 > file3 # this would then produce (in file3).
Name: Fred Bloggs
Employee Number: E666Note that paste puts horizontal tabs between the files, so you may need a sed 's/ //g' command to get rid of these.
$ sort /tmp/list_of_names # will sort the file into alphabetical order, and display it to the screen. Useful with option '-u' to filter out duplicates.
No comments:
Post a Comment