This file : how_linux.txt 05/05/2023 - gcw * Convert a text file to pdf landscape mode enscript -f Courier8 -B -r -o junk.ps junk.txt ps2pdf junk.txt * egrep cat bbb_sweep.raw | egrep -v '^\s' > junk.jnk * ***************************************************************** * *** .bash_aliases *********************************************** * ***************************************************************** #!/bin/bash echo "Hello World" PATH=.:$HOME/bin:/ubox/qlob/bin:$PATH alias lls='ls -alrt' alias ll='ls -l' alias llm='ls -l | more' alias lct='cut -c -120' export HOST_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}') export DISPLAY=$HOST_IP:0 export DD=/mnt/c/Users/warwargr/DD alias sshc='ssh greg@server.gregedu.com' * ***************************************************************** * ***************************************************************** alias lct cut -c -120 * ***************************************************************** * ***************************************************************** # fname=$(basename -- $1) fname=$1 bname="${fname%.*}" exstr="${fname##*.}" if [ "${exstr}" = "grg" ]; then gname="${bname}.scs" if [ -z "$2" ]; then seedstr="cap" else seedstr="$2" fi echo "" echo "* remapping ${fname} --> ${gname} -subst SEED ${seedstr}" echo "" else gname="${fname}" echo "" echo "* keeping ${fname} = ${gname}" echo "" fi * ***************************************************************** * ***************************************************************** #!/bin/bash read -p "Sync APDF *** PC <--- RH *** Continue? (Y/N): " \ -n1 confirm && echo "" && [[ $confirm == [yY] ]] || exit 1 echo "GREAT - Continuing" * ***************************************************************** *************************** To get the settings of LS_COLORS dircolors -b Set this in .bash_aliases see https://linuxhint.com/ls_colors_bash/ 31 = red 40 = black background 0 = default colour 32 = green 41 = red background 1 = bold 33 = orange 42 = green background 4 = underlined 34 = blue 43 = orange background 5 = flashing text 35 = purple 44 = blue background 7 = reverse field (exchange foreground and background color) 36 = cyan 45 = purple background 8 = concealed (invisible) 37 = grey 46 = cyan background 0 = default colour 90 = dark grey 47 = grey background 1 = bold 91 = light red 100 = dark grey background 92 = light green 101 = light red background 93 = yellow 102 = light green background 94 = light blue 103 = yellow background 95 = light purple 104 = light blue background 96 = turquoise 105 = light purple background 97 = white 106 = turquoise background 107 = white background no Global default fi Normal file di Directory ln Symbolic link. bd Block device cd Character device or Symbolic link to a non-existent file ex Executable file *.extension Example, *.mp3 dircolors -b | sed -e 's/:/\n/g' ************************* You can add 32bit support to linux with sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 for cadence I found sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libc6-i386 sudo apt-get install lib32z1 (it may be good to add more) (also people use "ldd" to trace down missing libs see https://askubuntu.com/questions/133389/no-such-file-or-directory-but-the-file-exists ) *********************************************************************** * login as super user, but with greg su - greg * This sets unlimited hard limits, and then changes user back to greg * (check with ulimit -H -a and ulimit -S -a) alias vvd="sudo bash -c 'ulimit -n 65535 && exec su - greg'" ************************************************************************* In bash, you can separate commands with ; You can also separate them with && or || && will execute the next one, if the previous command completes ok || will execute the next one, if the previous command doesn't complete ok ************************************************************************* tar xvmf file.tar (the "m" means don't modify the time - necessary for windows file systems) ************************************************************************* #!/bin/bash ShanLoc="Hello World" export ShanLoc ShanLoc="Hello Moon" bash -c 'echo $ShanLoc' (if you don't use the export, then new bash shell won't know $ShanLoc) ************************************************************************* ************************************************************************* greg@xubox:~$ cat /usr/local/bin/getput #!/bin/bash scp uia73657@rric001x.rr.us.conti.de:$1 getput_junk.txt install -D getput_junk.txt $1 ************************************************************************* ************************************************************************* Here's how I would create a tar file on gregbox tar zcf - bin | ssh qoffeene@qoffee.net "cat > www/gregbox/bin.tar.gz" Here's how I would create a local tar file of a remote directory ssh qoffeene@qoffee.net 'cd www && tar zcf - gregbox' > gregbox.tar.gz ***************************************************************************** ****************************************************************** * Nice example of untarring files and verifying them * need to run as root to preserve permissions * for example, put all this in run_cmds.sh * sudo ./run_cmds.sh #!/bin/bash fnameList=( C5_MSD_PDK.tar.gz PVS16.13.004.tar.gz SPECTRE18.10.169.tar.gz TannerTools.tar.gz ) echo "" for fname in "${fnameList[@]}" do echo "Extracting : $fname" tar xf tarfiles/$fname echo "Comparing : $fname" tar df tarfiles/$fname done echo "" echo "Done - Have a nice day" ****************************************************************** https://bencane.com/2014/01/27/8-examples-of-bash-if-statements-to-get-you-started/ * ****************************************************** * grep the layers out of a klayout layers file * ****************************************************** egrep '(name|source)' G6R2H_rev10_det.lyp | \ sed -z \ -e 's///g' \ -e 's/<\/name>\n//g' \ -e 's///g' \ -e 's/<\/source>//g' \ -e 's/@1//g' \ | awk '{printf("%-10s %-10s\n", $1, $2)}' MET3_det 33/0 MET4_det 36/40 HBL_det 121/127 HBD_det 121/168 HBC_det 121/197 TEXT 127/0 HBL_roic 121/154 HBC_roic 121/163 HBD_roic 121/169 SCL 121/159 AP 74/0 CB 76/0 CB2_WB 86/20 WBDMY 157/0 SR_ALL 162/2 prBound 108/0 * ****************************************************** - ------------------------------------ - print PATH line by line - ------------------------------------ echo $PATH | sed 's/:/\n/g' - ------------------------------------ - ------------------------------------ - check apps - ------------------------------------ ********************************** * show all packages installed * ******************************** apt list --installed * ******************************** * To check if a package is installed: /usr/bin/dpkg-query --show --showformat='${db:Status-Status}\n' PACKAGE apt -qq list PACKAGE dpkg -s PACKAGE | grep Status * To check what depends on what apt-cache depends PACKAGE apt-cache rdepends PACKAGE * To search for apt-cache search PACKAGE * To show everything about a package apt-cache show PACKAGE - ------------------------------------ - ------------------------------------ - trim to 120 columns ------------------------------------ ps aux | grep uia73657 | cut -b -120 ------------------------------------ ------------------------- zip squash.zip file1 file2 file3 zip -r squash.zip dir1 unzip squash.zip ------------------------- su df -h mount /dev/sdb1 mkfs.vfat /dev/sdb1 (you might need to use "fdisk /dev/sdb" first m - help o - create a new DOS partition table n - create a new partion t->b - change the partion type to FAT32 w - write to disk mkvs.vfat -n "KING8G" /dev/sdb1 * ************************************************* find LTS -type d -exec chmod ugo+x {} \; find . -maxdepth 1 -name '*.inc' -exec diff {} ~/zeptune \; find . -name "*.pdf" find ./GFG -name sample.txt find ./GFG -name *.txt find ./GFG -name sample.txt -exec rm -i {} \; find ./GFG -empty find ./GFG -perm 664 find ./ -type f -name "*.txt" -exec grep 'Geek' {} \; find ./test -maxdepth 2 -name "*.php" find ./test -not -name "*.php" find ./test ! -name "*.php" find -name '*.php' -o -name '*.txt' find ./test -name abc* find ./test -type f -name "abc*" find ./test -type d -name "abc*" find ./test ./dir2 -type f -name "abc*" find /etc -maxdepth 1 -perm /u=r find /bin -maxdepth 2 -perm /a=x find . -user bob find / -mtime 50 find / -atime 50 find / -mtime +50 –mtime -100 find /home/bob -cmin -60 find / -size +50M -size -100M find . -type f -exec ls -s {} \; | sort -n -r | head -5 find . -type f -exec ls -s {} \; | sort -n | head -5 find . -exec ls -ld {} \; find /tmp -type f -name "*.txt" -exec rm -f {} \; find /home/bob/dir -type f -name *.log -size +10M -exec rm -f {} \; https://www.binarytides.com/linux-find-command-examples/