Monday, 23 September 2024

How to install wifi driver in ubuntu?

ref: https://github.com/McMCCRU/rtl8188gu


sudo apt-get install build-essential git dkms
git clone https://github.com/McMCCRU/rtl8188gu.git
cd rtl8188gu
make
sudo make install
cd .. 
rm -rf rtl8188gu
sudo reboot

Thursday, 19 September 2024

How to restrict or limit a new ubuntu user from accessing other folder?

1. add a new user

sudo adduser newuser


2. add user to sudo group

sudo usermod -aG sudo newuser


3. add user to ssh group

sudo vim /etc/ssh/sshd_config

>>AllowUsers newuser


4. add restriction to the new user (space sensitive)

sudo visudo -f /etc/sudoers.d/newuser

>>newuser ALL=(ALL) ALL, !sudoedit, !/usr/bin/su, !/bin/su, !/bin/bash, !/bin/sh, !/usr/bin/chmod, !/usr/bin/chown, !/usr/bin/docker, !/usr/bin/passwd, !/usr/sbin/visudo


5. check the new restriction

sudo visudo -c

If it is ok, you will the following message print out:

/etc/sudoers: parsed OK

/etc/sudoers.d/README: parsed OK

/etc/sudoers.d/newuser: parsed OK


6. apply folder restriction to current user folder
sudo chmod -R 700 /home/currentuser

7. reboot the machine and check the restriction
sudo reboot
cd /home/currentuser
sudo chmod -R 777 /home/currentuser
sudo docker ps

How to ssh or scp without password?

 

Method 1: Use SSH Key-Based Authentication

The most secure and recommended way is to set up SSH key-based authentication, which doesn't require you to include a password in the command.


1. Generate SSH Key Pair (if you don’t have one already):

    ssh-keygen -t rsa -b 4096

Save the key in the default location (~/.ssh/id_rsa).


2. Copy Public Key to the Remote Machine:

ssh-copy-id username@remote_host -p 22

Replace username and remote_host with your remote machine's username and IP address or hostname.

3. Run rsync without Password or ssh into another machine without Password:

rsync -avz /path/to/source/ username@remote_host:/path/to/destination/

ssh username@remote_host -p 22


4. Change folder permission on destination folder.

sudo chmod -R 777 destination_folder

Monday, 22 July 2024

How to install ffmpeg offline using a static version?

Ref: https://johnvansickle.com/ffmpeg/

1. What is a static build and how do I install it?

static build is basically a binary with all the libs included inside the binary itself. There's no installation necessary in order to use a static binary, but you may want to place it in your shell's PATH to easily call it from the command line. Otherwise you can use the binary's absolute path. Here's a quick walkthrough:

Download the latest git build.

$ wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz

$ wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5


With the build and the build's md5 hash downloaded you can check its integrity.

$ md5sum -c ffmpeg-git-amd64-static.tar.xz.md5
ffmpeg-git-amd64-static.tar.xz: OK


Unpack the build. Note: If you need to do this on Windows, use 7-Zip to unpack it. You may have to run it twice; once to uncompress and again to untar the directory.

$ tar xvf ffmpeg-git-amd64-static.tar.xz


Now I have the directory "ffmpeg-git-20180203-amd64-static".

$ ls ffmpeg-git-20180203-amd64-static
ffmpeg  ffprobe  GPLv3.txt  manpages  model  qt-faststart  readme.txt


Please read readme.txt! (hit "q" to exit out of "less")

$ less ffmpeg-git-20180203-amd64-static/readme.txt


Without any further steps I can start using ffmpeg with my relative path to the binary.

$ ./ffmpeg-git-20180203-amd64-static/ffmpeg
ffmpeg version N-89948-ge3d946b3f4-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.4.0 (Debian 6.4.0-11) 20171206
(snipped output to save space)


Or using the absolute path to the binary.

$ /home/john/ffmpeg-git-20180203-amd64-static/ffmpeg
ffmpeg version N-89948-ge3d946b3f4-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.4.0 (Debian 6.4.0-11) 20171206
(snipped output to save space)


To globally install it I need to move the binary into my shell's path. "PATH" is a variable in your environment set to a list of colon seperated directories the shell uses to locate binaries. Here's my system's path.

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/john/.local/bin:/home/john/bin

Your output may look different than mine, but it will be a somewhat similar list of directories. When I run the command "ffmpeg", the shell will look in /usr/local/bin first and then the next directory to the right in above list until it's found. If there's not a binary named "ffmpeg" in any of the above directories the shell will return "ffmpeg: command not found".


Before moving the ffmpeg binary into the shell's path, check to see if an older version of ffmpeg is already installed.

$ whereis ffmpeg 
ffmpeg: /usr/bin/ffmpeg

This lists an older version of ffmpeg in /usr/bin installed via my package manager. I can either uninstall the older version or place the newer static ffmpeg binary in a path that's searched before /usr/bin. According to my shell's path that would be /usr/local/bin.


Move the static binaries ffmpeg and ffprobe into the shell's path.

$ sudo mv ffmpeg-git-20180203-amd64-static/ffmpeg ffmpeg-git-20180203-amd64-static/ffprobe /usr/local/bin/

$ whereis ffmpeg
ffmpeg: /usr/local/bin/ffmpeg

$ whereis ffprobe
ffprobe: /usr/local/bin/ffprobe



Now ffmpeg is globally installed and you're done!

$ ffmpeg
ffmpeg version N-89948-ge3d946b3f4-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.4.0 (Debian 6.4.0-11) 20171206
  (snipped output to save space)


Uninstall.

$ sudo rm /usr/local/bin/ffmpeg /usr/local/bin/ffprobe

Thursday, 4 July 2024

How to encode and decode character into ascii code?

 https://www.w3schools.com/tags/ref_urlencode.ASP


Character From Windows-1252 From UTF-8
space %20 %20
! %21 %21
" %22 %22
# %23 %23
$ %24 %24
% %25 %25
& %26 %26
' %27 %27
( %28 %28
) %29 %29
* %2A %2A
+ %2B %2B
, %2C %2C
- %2D %2D
. %2E %2E
/ %2F %2F
0 %30 %30
1 %31 %31
2 %32 %32
3 %33 %33
4 %34 %34
5 %35 %35
6 %36 %36
7 %37 %37
8 %38 %38
9 %39 %39
: %3A %3A
; %3B %3B
< %3C %3C
= %3D %3D
> %3E %3E
? %3F %3F
@ %40 %40

Thursday, 4 April 2024

How to print out ubuntu specs? Neofetch

sudo apt install neofetch -y

neofetch

neofetch --off (without any logo printed)