Linux tips and tricks for web-dev

logo with bird inside partially looks like penguin =)

Linux tips and tricks for web-dev's


  1. show file/folders rights in drxr & 777 formats:
       

    stat -c '%A %a %n' /<your_folder>/

  2. monitor changing file:

     tail -f -n 10 var/log/dev.log

  3. download big file with cURL:

     curl --location 'https://<your_url>' \ --header 'Authorization: Token <token>' -o file.name

  4. curl response with the following redirects:

    curl -iL --max-redirs 1 http://example.com

  5. monitor folder recursively for changes:

    inotifywait -m -e create,delete -r /<your_folder>
      6. removing all files in the folder except some needed 
           
        in zsh:
       setopt extended_glob
       rm -rv -- ^(.git|.idea)(D)

-r:  Recursively delete directories and their contents.
-v: Display what is being deleted.
--:  Denotes the end of options to prevent issues with filenames starting with hyphens.
^(pattern): Exclude files and directories that match the given pattern.
(.git|.idea): List of patterns to exclude (in this case, .git and .idea).
(D): Glob qualifier to match only plain files and directories, excluding symbolic links.

               in bash:
         shopt -s extglob
         rm -rv !(@(filename1|filename2|folder_to_keep))

-r: Recursive, to delete directories and their contents.
-v: Verbose, to display what is being deleted.

        7. live git log (almost real-time) 😅
    
    watch -ceb -n 1  git --no-pager log --graph --oneline --decorate --all --color

or creating an alias (you can add it to your .profile or .bashrc or .zshrc to the end of the file, don't being worrying to enter it each time):

    alias glowh='command watch -ceb -n 1 git --no-pager log --graph --oneline --decorate --all --color'

and invoking it by running the command glowh

---------------------------------------------------------------------

Adding ssh key

https://dev.to/emmanuelnk/using-sudo-without-password-prompt-as-non-root-docker-user-52bg

auto adding the key - keychain 2.8.5 ~ http://www.funtoo.org

sudo apt-get install keychain


add this bottom line to .bashrc

eval `keychain --eval --agents ssh id_rsa`


if you need more keys to be added to the agent use this in your .profile or .bashrc

eval `keychain --agents ssh --eval id_rsa1 folder/id_rsa2`

---------------------------------------------------------------------

ssh-agent -k

keychain --agents ssh ~/.ssh/id_rsa

access rights for the key and keys folder:

ssh directory permissions should be 700 (drwx- - - - - -).
The public key (. pub file) should be 644 (-rw-r--r- -).
The private key (id_rsa) on the client host, and the authorized_keys file on the server, should be 600 (-rw- - - - - - -).


How to create a user without a password:

adduser --disabled-password --shell /bin/bash --gecos "User" $username

You'll be able to:

su $username

The --disabled-password option will not set a password, meaning no password is legal, but login is still possible (for example with SSH RSA keys).

To create a user without a password, use passwd -d $username after the user is created to make the password empty. Note not all systems allow users with empty password to log in.


Other related to Linux console articles in this blog: 

Comments

Popular posts from this blog

Открываем порт для сервера Minecraft на роутере mikrotik (команда для терминала в WinBox)

Интересное о Формальдегиде