Posts

Showing posts with the label Terminal

How to install VirtualBox Guest Additions in ubuntu server 22.04 in terminal

Add you ~/.ssh/id_ed25519.pub key into ~/.ssh/authorized_keys , so you can use root@xx.xx.xx.xx sudo mount /dev/cdrom /media cd /media sudo apt install bzip2 sudo ./VBoxLinuxAdditions.run sudo reboot Then mount your host folder into guest os folder by using User Interface. Enjoy the life with virtualbox.  ​

How to install Nvidia Driver and Tensorflow/Pytorch GPU version in Ubuntu/PopOS 22.04 at HP Zbook Studio G8 laptop

1. Upgrade HP bios  You could directly use online bios update to update your bios fireware. Reboot -> F2 -> Esc -> Set up WiFi -> reboot -> F10 -> update bios in a online way Or you could use Windows system to do the update: https://support.hp.com/us-en/document/ish_3894564-1633733-16 2. Switch to integrated graphics only mode In popos, you can do it in right-top-corner icon, power settings. In ubuntu, you can do it in nvidia-settings -> profile-settings -> use integrated graphics reboot 3. Use gcc-12 which gcc # if gcc is not gcc-12, then do the following sudo rm /usr/bin/gcc sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc 4. Install nvidia special driver for your special gpu version For me, it’s GeForce RTX 3070 Mobile . From the nvidia driver download page, you could download a file like NVIDIA-Linux-x86_64-525.105.17.run https://www.nvidia.com/download/index.aspx?lang=en-us Then you do the following: sudo chmod 777 NVIDIA-Linux-x86_64- 525.105 . 17 ...

Bash script tutorial with a minimum example

It uses variable, function, for loop, if else: #!/bin/bash function hi () { #no matter what get print out, it will get returned author= $1 echo " ${author} : \n" echo "hi,\n" ; echo "you" ; } #yingshaoxo="$(echo yingshaoxo)" yingshaoxo= "yingshaoxo" var=$(hi $yingshaoxo ) echo -e $var echo -e $var echo -e "\n" my_list=( "dog" "human" "cat" ); for word in ${my_list[@]} ; do if [[ $word == "human" ]] ; then echo " ${word} !!!" elif [[ $word == "dog" ]]; then echo " $word ." else echo $word fi done exit The bash syntax is similar to PHP, which treats list and map data structure as one single object. Use declare -A map_name to declare a map Use declare -a list_name to declare a list More info:  https://www.geeksforgeeks.org/bash-scripting-array ...

How to lock and unlock a folder/file in MacOS from terminal (so that general program can't modify it

Launch Terminal.  sudo chflags uchg [file path] Press Enter. Unlock: chflags nouchg [file path] ​

A simple way to check if you got the Root Permission in your MacOS or not

Run: cp /bin/zsh /bin/zsh_backup cp /bin/bash /bin/zsh /bin/zsh --version If you see: cp: /bin/zsh_backup: Operation not permitted , then you don’t have the root permission at all. I would suggest you return that Mac Machine, because it doesn’t belong to you, you don’t have full control over it. Some of you may think you could go to the recovery terminal to do a remount to change the file system, but as far as I know, you can’t. Here is the command line, try it yourself: mount -uw '/Volumes/Macintosh HD' cd '/Volumes/Macintosh HD' cp ./bin/zsh ./bin/zsh_backup cp ./bin/bash ./bin/zsh I think I won’t buy apple products anymore. (except airpods pro, the version that have noise cancel function ​

Basic network knowledge for hackers

Some command lines you should know  ifconfig ipconfig ip address ping 192.168.1.1 telnet 192.168.1.1 22 ssh root@192.168.1.1 finger sudo -s iptables -S netstat -rn netstat traceroute 10.0.2.15 rustscan -a 10.0.2.15 -- -Pn -t 10000 nslookup google.com dig bing.com nmap 127.0.0.1 rustscan -a yandex.com -- -Pn -t 10000 whois baidu.com whois yingshaoxo.xyz xdg-open 'google.com/search?q=yingshaoxo' More information Search for: hacking path with xxx Search for: how to xxx ​

How to use OpenWRT(router) to make a VPN wifi with the help of v2ray

 https://github.com/yingshaoxo/how-to-set-up-v2ray-directly-in-openwrt

Rethink About tmux

You only need to know a few shortcuts: 1. start a new window: ctrl+b + & 2. list window: ctrl+b + w 3. delete a window: ctrl+b + & 4. keep it in background: ctrl+b + d 5. go back to tmux: tmux a

Essential Mac Terminal shortcuts

Command + T: create a new tab Shift + Command + { or }: switch between tabs Command + W: close a tab  https://support.apple.com/guide/terminal/keyboard-shortcuts-trmlshtcts/mac ​

Get Started to use Kubernetes with the help of minikube

Introduction https://minikube.sigs.k8s.io/docs/start/ https://www.youtube.com/watch?v=IMOZCDhH7do Brief idea Container – In Minikube, containers are used as the building blocks of creating applications. Pod – Pod is a collection of one or more containers that share storage and network resources. Pods contain the definition of how the containers should be run in Minikube. Minikube uses these definitions to maintain the necessary resources. For example, you can define you need two pods. During execution, if a pod goes down, Minikube will automatically fire up a new pod. Deployments — I don’t know this yet: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ Service – Because pods are replaceable, Minikube needs an abstraction layer to keep the interaction between the different pods seamless. For example, if a pod dies and a new pod is created, the application users shouldn’t get bogged down in the details of network addresses and related issues. Services ...

AutoSub Tutorial: how to add a subtitle to your video by using Python

Installation pip3 install git+https://github.com/agermanidis/autosub.git@master Usage autosub -S zh-CN -D zh-CN "/home/yingshaoxo/Videos/yingshaoxo.mp4" or autosub -S en -D en "/home/yingshaoxo/Videos/yingshaoxo.mp4" Add Subtitles to your video  ffmpeg -i 饥饿站台.mp4 -vf subtitles=饥饿站台.srt output.mp4 or ffmpeg -i input.mp4 -vf "subtitles=input.srt:force_style='Fontname=STSong'" -y output.mp4 ​

ctrl+r

 We use this to search for a historical command we have used in the terminal. I just found one thing that useful: we could actually repeatedly press ctrl+r to loop all possible commands that we may need.

dlib, cmake, c++, and linux

Download git clone https://github.com/davisking/dlib.git2 Install and Use under the folder of dlib, do the following: mkdir build; cd build; cmake .. ; cmake --build . For Python3 python setup.py install python3 opencv_webcam_face_detection.py For C++ Create a file at a new folder: `3d_point_cloud_ex.cpp # include <dlib/gui_widgets.h> # include <dlib/image_transforms.h> # include <cmath> using namespace dlib; using namespace std ; int main() { // Let's make a point cloud that looks like a 3D spiral. std:: vector <perspective_window::overlay_dot> points; dlib::rand rnd; for ( double i = 0 ; i < 20 ; i+= 0.001 ) { // Get a point on a spiral dlib:: vector < double > val( sin (i), cos (i),i/ 4 ); // Now add some random noise to it dlib:: vector < double > temp(rnd.get_random_gaussian(), rnd.get_random_gaussian(), ...

How to custom Nautilus shortcuts for 'Open in Terminator'

https://askubuntu.com/a/1062263 https://help.ubuntu.com/community/NautilusScriptsHowto 1. Create a script vim  ~/.local/share/nautilus/scripts/Terminator #! /bin/bash terminator --working-directory=$(pwd) sudo chmod 777  ~/.local/share/nautilus/scripts/Terminator 2. Create shortcuts vim  ~/.config/nautilus/scripts-accels F4 Terminator 3. Restart Nautilus nautilus -q 4. Test Press F4 to go to Terminator 

How to use wildcard character, Asterisk, correctly

Anybody knows * can match any file name under the current directory. But not all of us know **/* can match any subdirectory and its files. If you have to include all files under a directory, remember to use **/*, like this: "files": [   "main.js",   "app.js",   "web/dist/**/*" ],

Install Lubuntu20.04 at UEFI booting machine

-1. Delete all of your disk partitions. 0. Use default installing GUI for full-disk erasing installation It will fail, but it'll do some works for you. The error message is "command returned non-zero exit status. cannot set efi variable boot00003. efivarfs_set_variable invalid argument. failed to register the efi boot entry." Don't quit the USB OS yet. Open a terminal. do a check with `sudo df -hl`. I suppose now you have a 300MB fat32 partition at /dev/sda1, and an ext4 partition at /dev/sda2, that's good! 1. Reboot to your USB live system again, but don't install anything. Just open the terminal. 2. Chroot ``` sudo mount /dev/sda2 /mnt sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys #sudo modprobe efivarfs #do it only when you got error when execute grub-install sudo chroot /mnt #mount -t efivarfs efivarfs /sys/firmware/efi/efivars #do it only when you got error when execute grub-install...

Force Ubuntu apt to use HTTPS

As I said, I don't want anyone to spy on me. 1. backup sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup 2. change APT source sudo sed --in-place --regexp-extended 's http://(us\.archive\.ubuntu\.com|security\.ubuntu\.com) https://free.nchc.org.tw g' /etc/apt/sources.list 3. go to `/etc/apt/sources.list.d/`, replace all text with `http` to `https` 4. update software infomation, and see if all links becomes https sudo apt update

Access your Linux Files(especially your videos with thumbnail or preview) from your android phone

1. Install samba in your Linux https://ubuntu.com/tutorials/install-and-configure-samba#2-installing-samba Don't forget to create a user with the same name as your curretn Linux username: sudo smbpasswd -a your_username 2. Install Solid Explorer in your android phone https://play.google.com/store/apps/details?id=pl.solidexplorer2 3. Add your samba server to your phone Click Solid Explorer right-bottom 'add button' -> Click 'New cloud connection' -> Select 'LAN/SMB' -> Select your server -> Click 'Username and password' -> Fill it with the username and password that you have created before -> Click 'Next' -> Done! 4. Use Kodi is also a good idea sudo apt install kodi add samba server to your kodi:  https://kodi.wiki/view/Adding_video_sources#Adding_Remote_sources fix language problem: settings -> interface settings -> skin -> fonts -> arial based

Find big files in your Linux disk (so you can remove them later)

sudo du -B M . | sort -g | tail -n 20 or sudo du -a . | sort -n -r | head -n 20 or sudo find /var/lib/docker/containers/ -type f -name "*.log" -delete and du -h | sort -h

Master Git

Undo git add git reset Undo git commit but keep current files git reset --mixed HEAD~1 Undo git commit and restore old files git reset --hard HEAD~1 Return to the last commit git reset --hard HEAD~0 Create a branch git branch dev Go to that branch git checkout dev Push that branch to remote git push -u origin dev Merge that branch to current branch git merge dev Delete that branch git branch -d dev git push origin --delete dev