|
UNIX User Guide
Command Usage Q&A
Go back to previous directory: cd -
Display only directories with ls: ls -d */
How to save and exit emacs? Ctrl-X and Ctrl-C
How to use tar? for extracting files? tar -xvf for compress
files: tar -cvf
How to handle .gz file? gzip or gunzip
Use ping with address IP resolution: ping -sR cell
How to check disk usage? df
Quota for a user: du -sk This will show the usage for this user in kilobytes.
How to print from xpdf? click print button, then "lpr -Plpco"
How to set file access control list? setfacl -s user:pkamat:rw-,user::rw-,group::---,other:---,m:rwx
spwbde.pdf Also applied for the directory.
how to batch rename files? Use shell or perl program for file in *.htm
; do mv $file `echo $file | sed 's/\(.*\.\)htm/\1html/'` ; done #
change .htm files to .html
Wrong LineFeed! DOS to UNIX text file format conversion
Use "dos2unix" command
open with vi, :set ff=unix , or set ff=mac, then save it
col -bx <file1 >file2
g++ and gcc
When I encounter some problems with gcc compile source code, probably
cannot recognize finction as "sin" cos",
I use g++ to compile:
$g++ source1.c source2.c -o source
Plot with gnuplot
It is a tool to plot figures and curves , instead of MATLAB.
the two commands for print it:
gnuplot>set output "a.ps"
gnuplot>set term post
gnuplot>replot
gnuplot>quit
other options
gnuplot> set multiplot
gnuplot> set nomultiplot
gnuplt> clear
gnuplot > set xrange [20:50]
lp a.ps
Use Daily Cron Job
crontab -e to add some entry
crontab -l to list all jobs
file /etc/crontab
Or put something in /etc/cron.daily directory
Use AWK
Using AWK is more easy than perl to process TEXT file see
awk '$5 ~ /^1$/ { print ($3,$4,$5) >> "new_adj"}' scen_god
First, the $5 is a text separate default by space. It is mean the fifth
element of each line
~ means match
^ means beginning with $ means end with ($3,$4,$5) is actually printed
in the file separated with space, not comma
new_adj is the output file
scen_god is the input file
How to open XWindows application in another terminal?
In Linux or Unix, use "ssh -X" in your ssh process.
In Windows, use Exceed, then type
$xterm -display 10.0.0.1:0
10.0.0.1 is the IP address of the computer (not a NAT) which can be
resolved by remote host.
How to handle "_" character in Regular expressions
_ is not special. But if it is combined with a variable like $aa_, PERL
will interpret as a new variable $aa_, rather than $aa + '_'. So the
correct way to put it in is: ($aa)_.
For example, if $line ~= /^_($aa)_$/
Advanced Shell Tools
So what can you do with Regular Expressions? Lots! I don't have the time
to go into each utility in detail right now, but all of these use
regular expressions. Check their man pages for more detail on actual
usage:
Command and Description
awk Pattern Scanning & Processing Language
cut Select columns from stdin
diff Compare & Select differences in 2 files
grep Search every line of a file for an occurance of a regular
expression.
head Gives first few lines of specified file.
line Read in the first line of stdin
sed Edit streams of data
tail Select last few lines of a file (like head)
uniq Select unique lines & rows.
wc Count words, characters, & lines in a file.
Set up SSH passphrase between two machines
Basically, for a Public Key Encryption system to work.
Both two sides have to store the public key of each other.
Here, we have server and terminal:
Server store public key of client in $HOME/.ssh/authorized_keys
Clietn store public key of server in $HOME/.ssh/known_hosts
Attention: Each key is only one line ( one very long line) in the file.
Generally, client could trust the server if it like. So, Once this
occurs:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle
attack)!
It is also possible that the DSA host key has just been changed.
The fingerprint for the DSA key sent by the remote host is
14:b0:b4:42:01:5f:d6:20:69:4f:5b:e6:10:cb:65:cf.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this
message.
Offending key in /root/.ssh/known_hosts:3
DSA host key for 10.0.0.3 has changed and you have requested strict
checking.
Host key verification failed.
There could be solved by easily removed the offending line in
known_hosts file.
Examples:
It's important to know that there are essentially two versions of SSH
out in the wild. On most GNU/Linux systems the OpenSSH implementation is
installed which (these days) defaults to SSH protocol 2. On Windows SSH
Shell, the commercial version of SSH is installed (also using protocol
2).
|
|