Skip to main content

Some computer tips

to print screen of a program:
make a small terminal - import screen.jpg - click on the program.

computer can be shut off power while hibernate state.

ps x
kill -9 20034  // kill -9 forces to kill. kill is just try to kill nicely.


To copy symbolic links:
cp -d

vi search
/p.*.root ->

replace stuffs beginning with lrwx and ending with "root -> "
with "ln -s".
:%s/lrwx.*.root -> /ln -s /gc

ls -gok

check how many files/folders inside a folder.
ls EqTwoJet/ | wc -l

landshark-clued0:~/web_area> ln -s top_write /prj_root/2671/top_write/weigang
landshark-clued0:~/web_area> mkdir d0_private

firfox enable backspace:
about:config --> find "browser.backspace_action" --> change 2 to 0.

in c++, arcsine is asin();

at fermilab, the print command is "kprinter"
actually most of the time it doesn't work. so
1. print page to file "xx.pdf";
2. print pdf.
most of the time this way it's successful.

in term command line,
^a to the beginning
^e to the end.

To edit wiki, just click on "edit", not the pen.

list principles:
> klist

kill sam many jobs:
for i in `seq -f %8.0f 3894489 3894584`; do echo $i; qdel $i.d0cabsrv1.fnal.gov; sleep 1; done

------------------------------------------------------------------
to subscribe a fermilab mailist:

    from    my email
    to    listserv@fnal.gov
    subject    Subscribe fermiultimate
  
    subscribe fermiultimate my name
------------------------------------------------------------------


Wait 3 hours then play foo.mp3 :
sleep 3h ; mplayer foo.mp3

shell 计算器:
bc or python

scp server:filename . (from server to localhost)
scp filename servername:. (from localhost to server)


accessing windows drives from linux


1. su - to become root user
2. fdisk -l to see all your hard drives and partitions;
    anything that has NTFS or FAT32 or VFAT is a windows partition. Ignore Windows 95 Ext'd; they are not really a data partition.
3. mount -t type /dev/partition /mnt (or /media)
e.g.
    cd /media
    mkdir system
    mount -t ntfs /dev/sda1 /media/system
you can now view the contents of that drive.
    # ls /media/system/
4. when you are finished with the drive,
    umount /mnt

* note to be able to do step 2, you need to have all packages starting with ntfs installed.

env Lists your current environment variables and their settings:
$ whatis env
env (1)              - run a program in a modified environment


use alias to list command shortcuts:

$ alias
$ eject


$ pstree

 1191  tar -cvf pythia8135_new.tar pythia8135_new/
 1194  gzip pythia8135_new.tar

1196  scp pythia8135_new.tar.gz weigang@landshark-clued0.fnal.gov:/work/landshark-clued0/weigang

nan = not a number

to show Chinese characters:
gedit --encoding=gbk .fcitx/config


gcc is located at directory /usr/bin/gcc

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)


ps -ef | less
ps aux | less

the length of array should use const.


make all files under a folder readable to everyone:

landshark-clued0:/d0mino> chmod +r weigang -R

to list only hidden files:
ls -a | grep '^\.'

lp -d d0tcn_hp8150_d
lpq

klist -f
qstat -u weigang @d0cabsrv1



cat *.lst | sort | uniq
# merges and sorts all ".lst" files, then deletes duplicate lines.

the "if-grep" construct:
if grep -q Bash file
 then echo "File contains at least one occurrence of Bash."
fi
The "if COMMAND" construct returns the exit status of COMMAND.

These 3 are equivalent:
if [ $condition1 ] && [ $condition2 ]
if [ $condition1 -a $condition2 ]
if [[ $condition1 && $condition2 ]]

echo $MACHTYPE $OSTYPE $PS1 $PS2 $PROMPT_COMMAND $TERM $SHELL

$PATH: Path to binaries, /usr/bin/, /usr/local/bin/, etc.
may store in ~/.bashrc. 

cat /proc/cpuinfo

$ str=adasdf
$ echo ${#str}

Remove blank lines using grep
$ grep -v '^$' input.txt > output.txt

Comments

Popular posts from this blog

CKA Simulator Kubernetes 1.22

  https://killer.sh Pre Setup Once you've gained access to your terminal it might be wise to spend ~1 minute to setup your environment. You could set these: alias k = kubectl                         # will already be pre-configured export do = "--dry-run=client -o yaml"     # k get pod x $do export now = "--force --grace-period 0"   # k delete pod x $now Vim To make vim use 2 spaces for a tab edit ~/.vimrc to contain: set tabstop=2 set expandtab set shiftwidth=2 More setup suggestions are in the tips section .     Question 1 | Contexts Task weight: 1%   You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts . Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh , the command should use kubectl . Finally write a second command doing the same thing into ...

OWASP Top 10 Threats and Mitigations Exam - Single Select

Last updated 4 Aug 11 Course Title: OWASP Top 10 Threats and Mitigation Exam Questions - Single Select 1) Which of the following consequences is most likely to occur due to an injection attack? Spoofing Cross-site request forgery Denial of service   Correct Insecure direct object references 2) Your application is created using a language that does not support a clear distinction between code and data. Which vulnerability is most likely to occur in your application? Injection   Correct Insecure direct object references Failure to restrict URL access Insufficient transport layer protection 3) Which of the following scenarios is most likely to cause an injection attack? Unvalidated input is embedded in an instruction stream.   Correct Unvalidated input can be distinguished from valid instructions. A Web application does not validate a client’s access to a resource. A Web action performs an operation on behalf of the user without checkin...