Table of Contents

  1. AFS Commands
  2. Crontab Tasks
  3. Job Control
  4. File in Linux
  5. Shell Basics
  6. Check Infos
  7. Shell Variables
  8. Archive
  9. Others
organized by Xianwei Zhang, Nov 2015!

1. AFS Commands ↑top

(1) Access control list

(2) Ticket management

(3) Token management

(4) Create keytab file for pwdless login

(5) Script to renew tokens

(6) Restore AFS User files and Project Volumes

When you delete or change a file by mistake, you should first checked the backup directory, which contains a complete copy of all the directories, subdirectories, and files as they appeared the last time they were backed up (backup is usually done every midnight).

To view a Project Volume backup, you must mount it. Follow these steps:

    #-- login afs server
    #-- enter project volume directory
    $cd ~/private/bench/
    #-- get the volume
    $fs lq .
    Volume Name                    Quota       Used %Used   Partition
    cs.u.x.zhang.bench         200000000  141054086   71%         55%
    #-- mount the volume's backup, <proj-volume>.backup
    #--  e.g., volume is cs.u.x.zhang.bench, and backup should be cs.u.x.zhang.bench.backup
    $cd ~/private/simu10
    $fs mkm bench.1130 cs.u.x.zhang.bench.backup
    #-- now, restore the changed file
    $cp bench.1130/<filename> ~/private/bench
    #-- you don't need to unmount the volume, as files in .backup do not count against your disk quota usage
    #-- but unmounting is possible
    $fs rmmount bench.1130

If you failed to discover the mistake the same day, the only way to restore files is to contact technical staff to let them load backup tapes to restore the files.

More backup restore info can be found at CMU afs and Stanford afs

2. Crontab Tasks ↑top

3. Job Control ↑top

4. File in Linux ↑top

5. Shell Basics ↑top

visit blog1 and blog2 to learn more ...

(1) Shell info

6. Check Infos ↑top

(1) CPU info

(2) Process info

commands:

 $top
  $shift+A to have multi-window process view
  $type k and input PID to kill a process
  $type u and input user name to get process from the user alone
 detailed info
 $ps -Af

(3) Other info

(4) GLIBC

 $ldd --version
 $strings /usr/local/gcc-4.8.2/lib64/libstdc++.so.6 | grep LIBCXX
 $gcc --version
 $ldd <executable>
 
 /pin-2.13-62732-gcc.4.4.7-linux/intel64/runtime/cpplibs/libstdc++.so.6: version  `GLIBCXX_3.4.18' not found ( required by/obj-intel64/pinatrace.so), 
 $strings libstdc++.so.6 | grep GLIBCXX
 $cp /usr/local/gcc-4.8.2/lib64/libstdc++.so.6 .

(5) Count

$getconf PAGESIZE
cout word frequency in a file
$ tr ' ' '\n' < test.trace/test_anno  | grep memR | wc -l
$grep -o -c mem test.trace/test_anno

7. Shell Variables↑top

(1) Default value

 echo "default'=': dist= ${dist=1.0}"   #-- dist=1.0
 echo "after'=': dist= $dist"     #-- dist=1.0
 echo "---------"
 echo "default '-': weather= ${weather-sunny}" #-- weather=sunny
 echo "after '-': weather= $weather"    #-- weather= ('-' just use default, never set)
 echo "---------"
 weather="" #-- weather has been set, but just an empty value
 echo "default '-': weather= ${weather-sunny}" #-- weather=
 echo "default '=': weather= ${weather=sunny}" #-- weather=
 echo "default ':=': weather= ${weather:=sunny}" #-- weather= sunny
 echo "---------"
 unset weather #--weather now is unset
 echo "default '=': weather= ${weather=sunny}" #-- weather= sunny
 echo "default ':=': weather= ${weather:=sunny}" #-- weather= sunny

(2) Perform arithmetic operations

(3) Comparison

8. Archive↑top

(1) Creating an archive using tar

 $tar cvf archive_name dirname/ (note: no compression here)
    c -- create a new archive
    v -- verbosely list files which are processed
    f - following is the archive file name
 $tar cvfz archieve_name.tar.gz dirname/ (note: creating a tar gizpped archive)
    z -- filter the archive through gzip
    note: .tgz is same as .tar.gz
 $tar cvfj archive_name.tar.bz2 dirname/ (note: a bzip2 tar archive)
    j -- filter the archive through bzip2
    gzip vs bzip2: bzip2 takes more time to compress and decompress than gzip, but bzip2 is smaller in size
    note: .tbz and .tb2 is same as .tar.bz2

(2) Untar an arhive using tar

 $tar xvf archive_name.tar
    x -- extract files from archive
 $tar xvf archive_name.tar -C /target/dir 
    note: extract to a specified dir
 $tar xvfz archive_name.tar.gz
    note: extract a gizpped tar archive
 $tar xvfj archive_name.tar.bz2
    note: extract a bzipped tar archive

(3) Listing an archive using tar (without extracting)

 $tar tvf archive_name.tar
 $tar tvfz archive_name.tar.gz
 $tar tvfj archive_name.tar.bz2

(4) Extract a single file (from tar, tar.gz, tar.bz2)

 $tar xvf archive_file.tar /path/to/file
 $tar xvfz archive_file.tar.gz /path/to/file
 $tar xvfj archive_file.tar.bz2 /path/to/file
    extract a/multiple dirs from a tar archive
 $tar xvf archive_file.tar /path/to/dir1/ /path/to/dir2/
    extract group of files using regex
 $tar xvf archive_file.tar --wildcards '*.cpp'

(5) Adding a file or dir to an existing archive

 $tar rvf archive_name.tar newfile
    note: cannot add file or dir to a compressed archive

(6) Estimate the tar archive size before archiving

 $tar -cf - /dir/to/archive | wc -c
 $tar -czf - /dir/to/archive | wc -c
 $tar -cjf - /dir/to/archive | wc -c

9. Others↑top

(1) wget

(2) Mac double-click run

(3) Latex

underline

default \underline{} doesn’t allow line breaks; use \ul{} command of soul package instead:

Latex citations

black-circuled number

\usepackage{pifont}
\ding{202}
\ding{203}

figure/table numbered in section

\usepackage{chngcntr}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}

move up title

\usepackage{titling}
\setlength{\droptitle}{-9em}   % This is your set screw

reduce space bt author and title

\begin{document}

\title{Research Statement\vspace{-2ex}}
\author{Xianwei Zhang%\\
   % \texttt{xianeizhang@cs.pitt.edu}
   }
 \date{}
\maketitle

reduce section gap

\usepackage{titlesec}

%\titlespacing{command}{left spacing}{before spacing}{after spacing}[right]
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}