file permissions

file permissions r: 4 w: 2 x: 1 Read, write and execute (full) permission on a file in octal is 0+r+w+x = 0+4+2+1 = 7 Only Read and write permission on a file in octal is 0+r+w+x = 0+4+2+0 = 6 Only read and execute permission on a file in octal is 0+r+w+x = 0+4+0+1 = 5 Use above method to calculate permission for group and others. Let us say you wish to give full permission to owner, read & execute permission to group, and read only permission to others, then you need to calculate permission as follows: User = r+w+x = 0+4+2+1 = 7 Group= r+w+x = 0+4+2+0 = 6 Others = r+w+x = 0+0+0+1 = 1 ...

February 5, 2022 · 1 min

stat command in macos vs linux

stat command - Macos vs Linux The stat command isn’t standardized, so you can’t expect it to have the same behavior on all Unix variants. In practice, there’s BSD stat, and Linux stat, and many other variants don’t have a stat command. Method 1 macos only # octal permission format stat -f %p [FILE OR DIR] # or to remove front digits stat -f %Lp [FILE OR DIR] # User ID of file's owner. stat -f %u [FILE OR DIR] # Group ID of file's owner. stat -f %g [FILE OR DIR] # The size of file in bytes. stat -f %z [FILE OR DIR] # The time file was last accessed stat -f %a [FILE OR DIR] # The time file was last modified stat -f %m [FILE OR DIR] # when inode was changed stat -f %c [FILE OR DIR] # birth of time of inode stat -f %B [FILE OR DIR] Method 2 - macos only stat -f '%A %a %N' * # %A --- octal file permissions # %a --- ? # %N --- name of file or dir #755 1643740171 Q1.sh #755 1644072928 animal_farm #755 1644071333 check_string_length.sh #755 1643742200 comment.sh Method 3 - mac only stat -x foo Method 1 - Linux only stat --format '%A %a %N' * Method 2 - Linux only stat -c '%a %N' * # 644 'script.sh' # 755 'conditional.sh'

February 5, 2022 · 2 min

What in the word inode means in nix

What is the word inode mean in *nix ? speculated to be short for “index nodes introduced 1970’s short for index nodes. They were adopted into Linux in the 90s—and for good reason. They’re an excellent way to keep track of how your files are stored, and the method many systems are still based on today. An inode is a file data structure that stores information about any Linux file except its name and data. ...

February 5, 2022 · 1 min

find command in macos vs linux

find in macos vs linux find $HOME -path $HOME/$dir_name -prune -o \ -name "*$file_suffix" -exec cp {} $HOME/$dir_name/ \; find /Users/melky -path /Users/melky/Bkup -prune -o \ -name "*.sh" -exec cp {} /User/melky/bkup/ \;

February 3, 2022 · 1 min

Install vim-plugin if not installed

Install vim-plugin if not installed. " Install vim-plug if it's not already installed. if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw. github.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif

February 3, 2022 · 1 min

Three methods to install onedark theme in vim for aesthetics

Install onedark theme for vim URL https://github.com/joshdick/onedark.vim Method 1 - Use vim-plug Method 2 - Manual download the repo place colors/onedark.vim file in ~/.vimrc/colors/ place autload/onedark.vim file in ~/.vim/autoload/ cp ~/Downloads/colors/onedark.vim ~/.vimrc/colors/ cp ~/Downloads/autoload/onedark.vim ~/.vim/autoload/ Method 3 - Vim 8 Package Clone repo into ~/.vim/pack/*/opt/ The * in the path can be any value; see :help packages for more information.) ~/.vim/pack/*/opt/ add the following to .vimrc # add to ~/.vimrc packadd! onedark.vim

February 3, 2022 · 1 min

To fetch a single file from GitHub with curl or wget

To fetch a single file from GitHub, you can use curl or wget on Linux or macOS curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.github.com/junegunn/vim-plug/master/plug.vim

February 3, 2022 · 1 min

vimdiff

vimdiff vimdiff animals/cat.py animals/dog.py navigate form one change to another ]c + [c] do or :diffget (do stands for diff obtain) will move the change to the active window dp or :diffput (stands for diff put ) will push the change from the active window

February 3, 2022 · 1 min

SSH flags

# -v (verbose) option will give you details about the connection process of SSH. This is useful when troubleshooting a troublesome connection. ssh -v user@linuxconfig.org # To increase verbosity even further ssh -vvv user@linuxconfig.org # SSH Version on client machine ssh -V # OpenSSH_7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u 20 Dec 2019 $SHLVL Variable The $SHLVL variable tells you how many shells deep you are. echo $SHLVL To see which shells are already installed for your distribution, run cat /etc/shells. ...

January 29, 2022 · 1 min

Find & replace with vim

Find each occurrence of ‘foo’ (in all lines), and replace it with ‘bar’. Method 1 :%s/foo/bar/g Method 2 If you just want to delete all occurrences of “involve”, that is done with a standard vi command, e.g., :%s/\<involve\>//g The markers \< and \> are used to ensure that you do not change words such as “involved”, “involvement”, etc. Method 3 Try this search and replace: :%s/foo/bar/gc Change each ‘foo’ to ‘bar’, but ask for confirmation first. ...

January 26, 2022 · 1 min