1. HOME
  2. PDF

my Unix/Gnu Linux cheat sheat

Nasser M. Abbasi

September 11, 2023   Compiled on September 11, 2023 at 11:26am

Contents

 1 Links
 2 To use rsync for backup from 2 drives on windows from mounted shared folder using VBOX
 3 How to remove colors from terminal
 4 How to convert files in current folder from png to eps
 5 How to change extension of files in current folder
 6 recusrive tree search for string in files
 7 recusrive tree search for string in files with specific extension
 8 recusrive tree search for string in files, where the string is at start of a line
 9 recusrive tree search for string in files, print file name and the line with match
 10 recusrive tree search for string in files, print file name only where match found
 11 How to resize images in current folder based on width only
 12 How to find image width and height?
 13 How to resize animated gif file without losing the animation?
 14 How to batch convert all .png files to .jpg?
 15 How to install Linux on VBox
 16 to use shared folders on a VBOX with Linux guest to windows
 17 join AVI files to one
 18 How to change premissions recursive?
 19 How to delete lines from file that starts with #?
 20 How to search all tree and find file with specific name and then delete lines from this file that starts with #?
 21 tree command
 22 How copy selected files in one tree to another keeping same tree structure?
 23 How to increase file handles limit for a process?
 24 How to unzip a file using PHP on server?
 25 How to increase open file limit?
 26 How to run sudo command without getting command not found error?
 27 How to replace spaces in file names and folder with underscore?
 28 How to convert DOS file to Unix?
 29 bulk file renaming in bash, to remove name with spaces, leaving trailing digits
 30 How to convert djvu files to pdf?
 31 How to test the C compiler quickly?
 32 How to delete files with some extension inside specific folder over tree?
 33 How to download a web page using wget?
 34 How to delete folders inside tree with only specific name?
 35 How to delete files with specific names inside tree?
 36 How to sort files in tree by date changed?
 37 How print longest line in file?
 38 How to change all spaces to underscore in folder names in tree?
 39 apt useful commands
 40 How to start a command after some time
 41 How to mount shared windows folder from Linux guest using VMWARE?
 42 How to make guest OS (windows) see USB devices on Linux Host
 43 How to remove a network disk in windows?
 44 How to share folder using windows as guest and linux as host?
 45 How to find files on linux?
 46 How to check is samba is running?
 47 How to see what printers are there in Linux?
 48 How to extract first frame of animated gif file as png image?
 49 How to change title of Linux termina?
 50 How to slow down or speed up an existing animated gif file?
 51 Misc. useful linux commands
 52 How to find files that changed before sometime ago?
 53 How to change how window bars and windows (terminals) look like?
 54 How to test Linux performance using sysbench ?
 55 How to test Linux performance using geekbench ?
 56 How to stop window to snap/expand automatically when top edge hit the top of the desktop ?
 57 How to find line number which is longest in file?
 58 How to change line in all files in tree?
 59 How to delete lines in all files in tree that contain some specific text?
 60 How to remove some text from a line (but not delete the whole line)

  1. sed useful commands http://www.catonmat.net/blog/wp-content/uploads/ 2008/09/sed1line.txt
  2. apt and dpkg cheat sheet http://www.cyberciti.biz/tips/linux-debian- package-management-cheat-sheet.html
  3. scripting tutorial http://linuxconfig.org/bash-scripting-tutorial
  4. http://www.cyberciti. biz/faq/linux-unix-bsd-xargs-construct-argument-lists-utility/ has good commands to learn from, on xargs
  5. good hints on writing robust scripts http://www.davidpashley.com/articles/ writing-robust-shell-scripts/

2 To use rsync for backup from 2 drives on windows from mounted shared folder using VBOX

Assuming /media/G and /media/E are 2 different shared folders mounted allready and you are now inside Linux in VBox then do

rsync -av  --delete /media/G /media/E
 

3 How to remove colors from terminal

alias ls='ls --color=never'
 

4 How to convert files in current folder from png to eps

  #!/bin/bash 
    for file in *.png; do 
             filename=${file%.*} 
             convert "$filename.png" "$filename.eps" 
    done
 

5 How to change extension of files in current folder

To change extension from .PNG to lowe case .png

#!/bin/bash 
for file in *.PNG; do 
    f=${file%.*} 
    mv "$f.PNG" "$f.png" 
done
 

6 recusrive tree search for string in files

  grep -H -r "string I am searching for"  *
 

This should also work

 grep -H -r 'string I am searching for' *
 

also this

 find . -type f -exec grep -l 'string' {} \;
 

7 recusrive tree search for string in files with specific extension

 find . -name "*.txt" -print0 | xargs -0 egrep 'string'
 

8 recusrive tree search for string in files, where the string is at start of a line

 find . -name "*.txt" -exec egrep -l '^string' {} \;
 

9 recusrive tree search for string in files, print file name and the line with match

find . -type f -print0 | xargs -0 grep -H 'documentclass'
 

10 recusrive tree search for string in files, print file name only where match found

find . -type f -name *.tex -print0 | xargs -0 grep -l 'documentclass'
 

11 How to resize images in current folder based on width only

This example looks for all png files in current folder and will make thumbnails (shrink) any image that has a width larger than say 200 pixels. The height of the image is adjusted so that aspect ratio remain the same as originally was.

Edit as needed

#!/bin/bash 
shopt -s nullglob 
FILES=*.png 
for file in $FILES 
do 
     f=${file%.*} 
     echo "file is $file and f is $f" 
     convert "$f.png[200x>]" "$f"_thumb.png 
done
 

This example is as above except that the resizing is limited to enlarging the images to say 200 pixels. Edit as needed

#!/bin/bash 
shopt -s nullglob 
FILES=*.png 
for file in $FILES 
do 
     f=${file%.*} 
     echo "file is $file and f is $f" 
     convert "$f.png[200x<]" "$f"_thumb.png 
done
 

Reference:

  1. http://askubuntu.com/questions/135477/how-can-i-scale-all-images-in-a- folder-to-the-same-width
  2. http://www.cyberciti.biz/faq/bash-loop-over-file/

12 How to find image width and height?

Can use the file command. But the ouptput has to be parsed. easier to use imageinfo

>sudo apt-get install imageinfo  #install if needed 
>w=`imageinfo --width foo.png` 
>echo $w 
81 
 
>h=`imageinfo --height foo.png` 
>echo $h 
24
 

Reference:

  1. http://stackoverflow.com/questions/4670013/fast-way-to-get-image- dimensions-not-filesize

13 How to resize animated gif file without losing the animation?

Useful trick to know

convert big.gif -coalesce coalesce.gif 
convert -size 200x100 coalesce.gif -resize 200x10 small.gif
 

reference: http://stackoverflow.com/questions/718491/resize-animated-gif-file-without-destroying-animation

14 How to batch convert all .png files to .jpg?

Thanks to http://www.turnkeylinux.org/blog/png-vs-jpg

apt-get install imagemagick 
 
#one file 
convert -flatten -background white file.png file.jpg 
 
#batch 
for f in *.png; do 
    n=$(echo $f|sed 's/.png/.jpg/'); 
    convert -flatten -background white $f $n 
done
 

15 How to install Linux on VBox

PIC

16 to use shared folders on a VBOX with Linux guest to windows

Make sure first the windows folder is added to shared folder in VBox settings for the VM. Then boot the VM. Now inside Linux create a mount point where to mount the shared folder to

>sudo mkdir /media/nabbasi 
>ls -l  /media 
drwxr-xr-x  2 root root 4096 Jun 22 17:02 nabbasi 
 
>cd /media 
>sudo chown -hR me:me nabbasi 
>ls -l 
drwxr-xr-x  2 me   me   4096 Jun 22 17:02 nabbasi
 

Now mount the shared folder, making sure it is owned by me

>sudo ./win_mount.sh 
>cat win_mount.sh 
mount -t vboxsf -o uid=1000,gid=1000 nabbasi /media/nabbasi
 

17 join AVI files to one

Thanks to http://www.torrent-invites.com/showthread.php?t=194756

sudo apt-get install mencoder mplayer 
cat *.avi > movie.avi 
mencoder -forceidx -oac copy -ovc copy movie.avi -o movie_final.avi
 

18 How to change premissions recursive?

This will change all permissions on all files and folder

chmod -R 0755  folder_name
 

19 How to delete lines from file that starts with #?

This will change the file, backup is made to INPUT.txt.bak

sed -i.bak '/^#/d' INPUT.txt
 

20 How to search all tree and find file with specific name and then delete lines from this file that starts with #?

the -I {} is the marker, which says the file name is {}

find . -type f -name INPUT.txt -print0 | xargs -0 -I {}  sed -i.bak '/^#/d' {}
 

The above could also be done like this

find . -type f -name INPUT.txt -print0 | xargs -0 sed -i.bak '/^#/d'
 

But I found using explicit marker for the argument more clear. This is useful. If using a command that needs more than one argument, the marker is needed anyway, so might as well get used to using it. Marker can be anything. So this works also

find . -type f -name INPUT.txt -print0 | xargs -0 -I file  sed -i.bak '/^#/d' file
 

21 tree command

tree -n -L 1 --charset nwildner prints one level only and this tree -n -i -L 1 -d . does not print indentation lines

22 How copy selected files in one tree to another keeping same tree structure?

see http://unix.stackexchange.com/questions/83593/copy-specific-file-type-keeping-the-folder-structure

23 How to increase file handles limit for a process?

ulimit -n to find the limit, and to increase it to say 2048, type ulimit -S -n 2048

24 How to unzip a file using PHP on server?

Put this in a file foo.php and put it in the folder to unzip the file on the server and type the URL to this file

<?php 
    //phpinfo(); 
    //echo exec('whoami'); 
 
    $command = "unzip file.zip   > /dev/null 2>/dev/null &"; 
    $output = shell_exec($command); 
        echo "<pre>Done !</pre>"; 
?>
 

25 How to increase open file limit?

type unlimt -a to see all limits. To change open file limit, edit the file /etc/security/limits.conf as root and add these lines

* soft nofile 4096 
* hard nofile 4096
 

I rebooted after this just in case (may be reboot is not needed). Now it works. When I do

>ulimit -n 
4096
 

Reference: thanks to lornix answer

26 How to run sudo command without getting command not found error?

Use sudo -E env "PATH=$PATH"  command. Reference http://superuser.com/questions/709515/command-not-found-when-using-sudo

27 How to replace spaces in file names and folder with underscore?

find /tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;

Above is thanks to Dennis Williamson from http://stackoverflow.com/questions/2709458/bash-script-to-replace-spaces-in-file-names

Seems to work well.

28 How to convert DOS file to Unix?

tr -d '\015' < file.txt > new_file.txt

Just make sure not to use the same file above, else it will be wiped out.

http://stackoverflow.com/questions/2613800/how-to-convert-dos-windows-newline-crlf-to-unix-newline-n-in-bash-script

or just do sudo apt-get install dos2unix and type dos2unix foo.txt it will overwrite the file ok.

29 bulk file renaming in bash, to remove name with spaces, leaving trailing digits

Thanks to Avinash Raj, use this command rename 's/.*\s//' *.pdf see http://stackoverflow.com/questions/34469075/bulk-file-renaming-in-bash-to-remove-name-with-spaces-leaving-trailing-digits

30 How to convert djvu files to pdf?

Install sudo apt-get install djvulibre-bin. To convert multiple files, I wrote this small script

#!/bin/bash 
#dj2pdf.sh    script to convert djvu files to pdf 
set -x 
for file in $1; do 
    filename=${file%.*} 
    ddjvu -format=pdf -quality=100 "$filename.djvu" "$filename.pdf" 
done
 

To convert one file, type dj2pdf  file.djvu and to convert multiple files, type dj2pdf  "*.djvu"

31 How to test the C compiler quickly?

echo "void main(){printf(\"hello world\n\");}" |gcc -x c - -o /tmp/hello;/tmp/hello
 

32 How to delete files with some extension inside specific folder over tree?

thanks to Anderson M. Gomes http://unix.stackexchange.com/questions/270071/how-to-delete-all-files-with-specific-extension-in-specific-named-folders-in-lar

Here is the code

#to check 
$ find /path/to/source -type d -name 'rules' -exec find '{}' -mindepth 1 -maxdepth 1 -type f -iname '*.pdf' -print ';' 
 
#to delete 
$ find /path/to/source -type d -name 'rules' -exec find '{}' -mindepth 1 -maxdepth 1 -type f -iname '*.pdf' -print -delete ';'
 

33 How to download a web page using wget?

An example,

wget --recursive --no-clobber --page-requisites --html-extension --convert-links 
     --restrict-file-names=windows --domains the_domain_name.com --no-parent http://blabla_blabla
 

34 How to delete folders inside tree with only specific name?

Answers thanks to https://stackoverflow.com/questions/13032701/how-to-remove-folders-with-a-certain-name

cd top_level 
rm -rf `find . -type d -name folder_name_to_remove`
 

Or

cd top_level 
find . -type d -name foo -a -prune -exec rm -rf {} \;
 

35 How to delete files with specific names inside tree?

cd top_level 
find . -name "file_name" -print 
find . -name "file_name" -delete
 

36 How to sort files in tree by date changed?

This will list all files in tree, showing date file changed with latest changed at bottom of listing shown.

find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
 

Thanks to https://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s

37 How print longest line in file?

awk '{ if ( length > x ) { x = length; y = $0 } }END{ print y }' ./file.tex
 

Thanks to Keith Thompson at https://unix.stackexchange.com/questions/24509/how-to-print-the-longest-line-in-a-file

38 How to change all spaces to underscore in folder names in tree?

Use

sudo apt install detox 
detox -n --dry-run *  #dry run, to test, does nothing. 
detox *
 

This will change all folder names below where it is issued and changes any space in the name to underscore.

39 apt useful commands

To just update a program to its latest without knowing the version number do, say want to update gfortran

 sudo apt-get upgrade gfortran

To update the distribution do

 sudo apt-get dist-upgrade

40 How to start a command after some time

To start a command after some time, say 30 minutes do sleep 30m &&  ./my_script 

To start a command after some time, say 2 hrs do sleep 2h &&  python ./script.py

The above can be canceled before the time elapses, and the command will not run.

41 How to mount shared windows folder from Linux guest using VMWARE?

This was very tricky. Here are the steps I did. This is on Linux Ubuntu as guest running inside the VMWare virtual machine with windows 7 as Host.

First I made sure shared folder is added when installing the guest OS in VMWare setup. Added "data" as my shared folder name.

After booting into Linux, did (as user called "me")

sudo apt-get install open-vm-tools open-vm-tools-desktop open-vm-tools-dkms 
cd /mnt 
sudo mkdir -p /mnt/hgfs/data 
sudo sudo chown -hR me:me data  #this sets me as owner. This is important 
vmhgfs-fuse .host:data /mnt/hgfs/data
 

Do NOT use sudo in the last command above. When I did that, I got permission error.

42 How to make guest OS (windows) see USB devices on Linux Host

Make sure you are in vboxsers group

 sudo usermod -a -G vboxusers <useruame> 

logout and login. Now try to add USB 2.0 to VBox USB in settings of the window virtual machine. It should now be enabled.

43 How to remove a network disk in windows?

in windows DOS, type

net use G: /delete

Where G: is say the network disk

44 How to share folder using windows as guest and linux as host?

Made my /home/me/data/ as shared folder in VBox setting. So shared folder shows as data then.

Booted VBox windows 7. Then in windows typed in DOS

Type net use G: \\vboxsvr\data

So now it shows in windows as derive G

45 How to find files on linux?

sudo updatedb then locate file_name can also use find but locate is faster.

46 How to check is samba is running?

smbclient -L localhost if it asks for password, type it. It is then running.

47 How to see what printers are there in Linux?

lpstat -p

or do http://localhost:631/printers/ and select Printers from the menu. The above is CUSP interface.

48 How to extract first frame of animated gif file as png image?

convert 'moving_disk.gif[0]' moving_disk.png

49 How to change title of Linux termina?

Thanks to https://askubuntu.com/questions/22413/how-to-change-gnome-terminal-title type

PROMPT_COMMAND='echo -ne "\033]0;TITLE HERE\007"'

This will change the title in the terminal banner, normally located in the upper left corner.

To make the terminal title be the full path of the current folder, type

PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'

To make the terminal title be the last folder in full path of the current folder, type

PROMPT_COMMAND='echo -ne "\033]0;$(basename $(pwd))\007"'

50 How to slow down or speed up an existing animated gif file?

Thanks to http://blog.floriancargoet.com/slow-down-or-speed-up-a-gif-with-imagemagick/

identify -verbose your.gif  grep Delay| give current delay between each frame in 100’th of second. So it it say 50x100 then the delay is half second. To change the delay to one second between each frame do

convert -delay 100x100 your.gif your_slow.gif

So to make the time 0.25 second between each frame do

convert -delay 25x100 your.gif your_slow.gif

It looks like 6x100 is min time betweeb frames that browsers support. But this could depend on which browser.

51 Misc. useful linux commands

  1.  cd - goes back to last directory
  2.  reset clears and resets the terminal
  3. if you type  apt update then want to do it again by adding sudo then no need to retype everything, just type  sudo !!  then the  !!  will copy the last command
  4.  history followed by  !nn where nn is the command number show in history, will run that command
  5. To run 2 commands one after the other, but stop if one fail, do  cmd1; cmd2; cmd3 The above will stop if one of these commands fail. If you use  cmd1&& cmd2&& cmd3 then it will not stop if one command fail. so using ; is more safe.
  6.  command  column t| is useful command to format messy output into columns so easier to read

52 How to find files that changed before sometime ago?

use the command  find . -type f -mmin -150  to find files that changed within 150 minutes ago. And the command  find . -type f -mmin +150  to find files that changed longer than 150 minutes ago.

53 How to change how window bars and windows (terminals) look like?

on xfce, right click on the desktop->applications->settings manager->windows manager-> then select a theme. The theme Moheli looks good.

54 How to test Linux performance using sysbench ?

Install sysbench which is avaliable in all installation managers.

Use >sysbench --help for help. No man pages?

Then do

>sysbench cpu run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 1 
Initializing random number generator from current time 
 
 
Prime numbers limit: 10000 
 
Initializing worker threads... 
 
Threads started! 
 
CPU speed: 
    events per second:  3983.04 
 
General statistics: 
    total time:                          10.0005s 
    total number of events:              39839 
 
Latency (ms): 
         min:                                    0.23 
         avg:                                    0.25 
         max:                                   20.25 
         95th percentile:                        0.26 
         sum:                                 9943.89 
 
Threads fairness: 
    events (avg/stddev):           39839.0000/0.00 
    execution time (avg/stddev):   9.9439/0.00
 

And

>sysbench memory run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 1 
Initializing random number generator from current time 
 
 
Running memory speed test with the following options: 
  block size: 1KiB 
  total size: 102400MiB 
  operation: write 
  scope: global 
 
Initializing worker threads... 
 
Threads started! 
 
Total operations: 74842059 (7482566.83 per second) 
 
73087.95 MiB transferred (7307.19 MiB/sec) 
 
 
General statistics: 
    total time:                          10.0013s 
    total number of events:              74842059 
 
Latency (ms): 
         min:                                    0.00 
         avg:                                    0.00 
         max:                                   10.37 
         95th percentile:                        0.00 
         sum:                                 4017.76 
 
Threads fairness: 
    events (avg/stddev):           74842059.0000/0.00 
    execution time (avg/stddev):   4.0178/0.00
 

or

>sysbench --threads=5 memory run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 5 
Initializing random number generator from current time 
 
 
Running memory speed test with the following options: 
  block size: 1KiB 
  total size: 102400MiB 
  operation: write 
  scope: global 
 
Initializing worker threads... 
 
Threads started! 
 
Total operations: 89536061 (8944801.69 per second) 
 
87437.56 MiB transferred (8735.16 MiB/sec) 
 
 
General statistics: 
    total time:                          10.0028s 
    total number of events:              89536061 
 
Latency (ms): 
         min:                                    0.00 
         avg:                                    0.00 
         max:                                   46.68 
         95th percentile:                        0.00 
         sum:                                27564.97 
 
Threads fairness: 
    events (avg/stddev):           17907212.2000/1640514.61 
    execution time (avg/stddev):   5.5130/0.11
 

or

 
>sysbench --threads=5 cpu run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 5 
Initializing random number generator from current time 
 
 
Prime numbers limit: 10000 
 
Initializing worker threads... 
 
Threads started! 
 
CPU speed: 
    events per second:  6707.45 
 
General statistics: 
    total time:                          10.0036s 
    total number of events:              67111 
 
Latency (ms): 
         min:                                    0.23 
         avg:                                    0.74 
         max:                                   56.90 
         95th percentile:                        2.22 
         sum:                                49553.41 
 
Threads fairness: 
    events (avg/stddev):           13422.2000/856.28 
    execution time (avg/stddev):   9.9107/0.03
 

And

>sysbench --threads=5 --file_test_mode="seqwr" fileio run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 5 
Initializing random number generator from current time 
 
 
Extra file open flags: (none) 
128 files, 16MiB each 
2GiB total file size 
Block size 16KiB 
Periodic FSYNC enabled, calling fsync() each 100 requests. 
Calling fsync() at the end of test, Enabled. 
Using synchronous I/O mode 
Doing sequential write (creation) test 
Initializing worker threads... 
 
Threads started! 
 
 
File operations: 
    reads/s:                      0.00 
    writes/s:                     36.47 
    fsyncs/s:                     101.22 
 
Throughput: 
    read, MiB/s:                  0.00 
    written, MiB/s:               0.57 
 
General statistics: 
    total time:                          10.1126s 
    total number of events:              753 
 
Latency (ms): 
         min:                                    0.00 
         avg:                                   66.82 
         max:                                  655.80 
         95th percentile:                      337.94 
         sum:                                50315.70 
 
Threads fairness: 
    events (avg/stddev):           150.6000/63.87 
    execution time (avg/stddev):   10.0631/0.04
 

To use on windows go to https://github.com/akopytov/sysbench but need WSL to use.

The compiled tests are

ompiled-in tests: 
  fileio - File I/O test 
  cpu - CPU performance test 
  memory - Memory functions speed test 
  threads - Threads subsystem performance test 
  mutex - Mutex performance test
 

Reference https://linuxconfig.org/how-to-benchmark-your-linux-system

55 How to test Linux performance using geekbench ?

Installed geekbench on Linux Majoaro using the installation manager (from AUR).

Then did

>geekbench --help 
Geekbench 5.4.5 Tryout : https://www.geekbench.com/ 
 
Usage: 
 
  geekbench [ options ] 
 
Options: 
 
  -h, --help                print this message 
  --unlock EMAIL KEY        unlock Geekbench using EMAIL and KEY 
 
  --cpu                     run the CPU benchmark 
  --sysinfo                 display system information and exit 
[0911/024243:WARNING:src/halogen/cuda/cuda_library.cpp(1465)] Cannot find or load CUDA library. 
[0911/024243:WARNING:src/halogen/cl/opencl_library.cpp(691)] Cannot find or load OpenCL library. 
[0911/024243:WARNING:src/halogen/vulkan/vulkan_common.h(28)] VulkanException: vkCreateInstance(&info, nullptr, &instance) returned -9 (VK_ERROR_INCOMPATIBLE_DRIVER) 
 
  If no options are given, the default action is to run the CPU benchmark.
 

To run the tests did

>geekbench --sysinfo 
System Information 
  Operating System              Manjaro Linux 
  Kernel                        Linux 5.15.53-1-MANJARO x86_64 
  Model                         innotek GmbH VirtualBox 
  Motherboard                   Oracle Corporation VirtualBox 
  BIOS                          innotek GmbH VirtualBox 
 
Processor Information 
  Name                          Intel Core i9-12900K 
  Topology                      1 Processor, 6 Cores 
  Identifier                    GenuineIntel Family 6 Model 151 Stepping 2 
  Base Frequency                3.19 GHz 
  L1 Instruction Cache          32.0 KB x 6 
  L1 Data Cache                 48.0 KB x 6 
  L2 Cache                      1.25 MB x 6 
  L3 Cache                      30.0 MB x 6 
 
Memory Information 
  Size                          50.9 GB
 

Then now run the full test

>geekbench 
Geekbench 5.4.5 Tryout : https://www.geekbench.com/ 
 
Geekbench 5 requires an active Internet connection when in tryout mode and 
automatically uploads benchmark results to the Geekbench Browser. 
 
Buy a Geekbench 5 license from the Primate Labs Store to enable offline use 
and unlock other features: 
 
  https://store.primatelabs.com/v5 
 
Enter your Geekbench 5 license using the following command line: 
 
  geekbench --unlock <email> <key> 
 
  Running Gathering system information 
System Information 
  Operating System              Manjaro Linux 
  Kernel                        Linux 5.15.53-1-MANJARO x86_64 
  Model                         innotek GmbH VirtualBox 
  Motherboard                   Oracle Corporation VirtualBox 
  BIOS                          innotek GmbH VirtualBox 
 
Processor Information 
  Name                          Intel Core i9-12900K 
  Topology                      1 Processor, 6 Cores 
  Identifier                    GenuineIntel Family 6 Model 151 Stepping 2 
  Base Frequency                3.19 GHz 
  L1 Instruction Cache          32.0 KB x 6 
  L1 Data Cache                 48.0 KB x 6 
  L2 Cache                      1.25 MB x 6 
  L3 Cache                      30.0 MB x 6 
 
Memory Information 
  Size                          50.9 GB 
 
 
Single-Core 
  Running AES-XTS 
  Running Text Compression 
  Running Image Compression 
  Running Navigation 
  Running HTML5 
  Running SQLite 
  Running PDF Rendering 
  Running Text Rendering 
  Running Clang 
  Running Camera 
  Running N-Body Physics 
  Running Rigid Body Physics 
  Running Gaussian Blur 
  Running Face Detection 
  Running Horizon Detection 
  Running Image Inpainting 
  Running HDR 
  Running Ray Tracing 
  Running Structure from Motion 
  Running Speech Recognition 
  Running Machine Learning 
 
Multi-Core 
  Running AES-XTS 
  Running Text Compression 
  Running Image Compression 
  Running Navigation 
  Running HTML5 
  Running SQLite 
  Running PDF Rendering 
  Running Text Rendering 
  Running Clang 
  Running Camera 
  Running N-Body Physics 
  Running Rigid Body Physics 
  Running Gaussian Blur 
  Running Face Detection 
  Running Horizon Detection 
  Running Image Inpainting 
  Running HDR 
  Running Ray Tracing 
  Running Structure from Motion 
  Running Speech Recognition 
  Running Machine Learning 
 
 
Uploading results to the Geekbench Browser. This could take a minute or two 
depending on the speed of your internet connection. 
 
Upload succeeded. Visit the following link and view your results online: 
 
  https://browser.geekbench.com/v5/cpu/17190798 
 
Visit the following link and add this result to your profile: 
 
  https://browser.geekbench.com/v5/cpu/17190798/claim?key=464173
 

The result is

pict

Figure 1: Benchmarks before disabling hyper_V

The above was run on Virtual box. It shows it is slow peformance. So I disabled Hyper-V on windows 10. Using instructions given in https://www.wintips.org/fix-virtualbox-running-very-slow-in-windows-10-11/ (make sure to follow all instructions, include issuing the command line and rebooting windows).

In addition to the above, I made sure in VBox setting to use KVM for virtualization. See https://superuser.com/questions/945910/how-to-select-paravirtualization-interface-in-virtualbox

The peformance now is much better.

pict

Figure 2: Benchmarks after disabling hyper_V

56 How to stop window to snap/expand automatically when top edge hit the top of the desktop ?

This is the most stupid and annoying feature in Linux desktop and impossible to find how to turn it off. Googling around, this worked

xfconf-query -c xfwm4 -p /general/tile_on_move -s false
 

No wonder Linux will never ever make it on the desktop.

57 How to find line number which is longest in file?

awk '{ print length(), NR | "sort -rn" }' index.tex | head -n 1
 

This prints 2 numbers on the screen. The first number is the actual length and the second number is the line number itself in the file.

Thanks to Attila O. https://askubuntu.com/questions/375832/how-to-get-longest-line-from-a-file

58 How to change line in all files in tree?

Suppose we wanted to replace text in any line in files in some tree.

Do

#!/bin/bash 
 
cd $HOME/my_tree 
 
find . -name "fricas_listA.txt"|while read fname; do 
  echo "processing $fname" 
  sed -i 's/algorithm="fricas"/algorithm=""fricas""/g'  $fname 
done
 

The above replaces algorithm="fricas" by algorithm=""fricas"" everywhere in all files called fricas_listA.txt in the tree. To apply this to all text file, replace -name "fricas_listA.txt" by -name "*.txt"

59 How to delete lines in all files in tree that contain some specific text?

Suppose we wanted to delete all lines that has some word, say window in them.

Do

#!/bin/bash 
 
cd $HOME/my_tree 
 
find . -name "*.txt"|while read fname; do 
  echo "processing $fname" 
  sed -i '/windows/d' $fname 
done
 

60 How to remove some text from a line (but not delete the whole line)

Suppose we wanted to delete only the word window from any line.

Do

#!/bin/bash 
 
cd $HOME/my_tree 
 
find . -name "*.txt"|while read fname; do 
  echo "processing $fname" 
  sed -i 's/windows//g' $fname 
done