Posts

How to make a file executable (script) in Linux

Image
How to make a file executable (script) in Linux 1. open your command line, Terminal  In Linux Mint OS, I open the terminal command line by clicking on the LM logo (on the top right corner) and it will show the search bar and I type terminal on that search bar and click on the terminal apps. as shown on image below: 2. In the terminal prompt I type the word echo hello. Echo is build in linux command to echo the word that you type as shown below 3. I will make a script (an executable file) name “myfirstscript”, that when I type the script $ myfirstscript will echo the word hello 4. use a vi editor or nano or a text editor to make a file and input the command: echo hello, as shown below. Because I use vi editor, after i press enter, it will show the content of the file as shown below. It will have nothing in its content because it is a new file. to start typing using vi editor, i will need to press the keyboard key "i" means insert and type the word echo hello as shown below Not

login website quicker using linux command line

As a Linux sys-admin we will face many logins and has to remember username passwords. I want to share how to akses quicker without remembering username or password #make a script below  echo "username" |xclip -sel clip |chromium-browser (input url address for login) sleep 5 echo "password" |xclip -sel clip --------  Explanation of the script above 1. echo "username" |xclip -sel clip  <-- will copy to clipboard your username 2. echo "username" |xclip -sel clip | chromium-browser (input url address for login https://...) <-- the second part of the first line will open the login url https://.... in the chromium browser. or open with another version of google chrome browser use below command: google-chrome (input url address for login) to open in firefox firefox (input url address for login) 3. sleep 5 <------ will wait for 5 seconds until execute the next command In sleep 5 seconds can be arrange longer if the usual login loading in browser

Copy to clipboard from command line

How to copy to clipboard from command line: # Make the script below echo "anyword to copy" |xclip -sel clip ---- How this command after execute. It will copy to clipboard the "anyword to copy" and do keyboard key Ctrl-v to copy it to any place need.

Ansible

Ansible is a software tool from Redhat to make automation task between ansible master host and client. Step by step configuration and simple playbook to run ansible 1. installation on master system in redhat/centos: yum install ansible -y 2. configure the /etc/ansible/hosts file to input group and add the clients hosts inside the grup  [ansible_client] <--- group name 192.168.2.11 ansible_ssh_user= root  ansible_ssh_pass= password <---- IP of client, username of client and client password 3. make a playbook that use a yml language  sample.yml  <-- sample playbook file ---- - name: sample book   hosts: ansible_client <--- group name that we input in the ansible host file   remote_user: root   become: true   tasks:       - name: install httpd          yum:                 name: httpd                 state: latest       - name: run httpd          service:                   name: httpd                   state: started        - name: create content          copy:                

How to find files that have a specific content in linux

How to find files that have a specific content # find /usr | grep limits.h | xargs -I {} grep -H 'NAME_MAX' {}  Sample output: /usr/include/linux/limits.h:#define NAME_MAX         255 /* # chars in a file name */ /usr/include/linux/limits.h:#define XATTR_NAME_MAX   255 /* # chars in an extended attribute name */ /usr/src/linux-headers-4.15.0-54/include/uapi/linux/limits.h:#define NAME_MAX         255 /* # chars in a file name */ /usr/src/linux-headers-4.15.0-54/include/uapi/linux/limits.h:#define XATTR_NAME_MAX   255 /* # chars in an extended attribute name */ /usr/src/linux-headers-4.15.0-151/include/uapi/linux/limits.h:#define NAME_MAX         255 /* # chars in a file name */ /usr/src/linux-headers-4.15.0-151/include/uapi/linux/limits.h:#define XATTR_NAME_MAX   255 /* # chars in an extended attribute name */

how to access server linux ssh without key and hidden password

An alternatife way to access linux server without ssh key-gen and without people knowing password  sshpass -f filenameofpassword.txt ssh  -o StrictHostKeyChecking=no username @ip-address

How to open bible book in the browser using linux command line script

Image
I often open my online bible and study but have a hard time to open quicker where the passage I want to open. So I make a Linux script to open it quickly. Follow the steps below. Thank you. Note: It can also use to open other specific website 1. make a file and input firefox https://www.biblegateway.com/passage/?search="$1"+$2  to open bible using firefox or  google-chrome chromium-browser https://www.biblegateway.com/passage/?search="$1"+$2  or  chromium-browser https://www.biblegateway.com/passage/?search="$1"+$2  to open bible using chrome 2. don't forget to chmod 700 <filename> to make the file executable 3. test your script by typing in command line:  # <filename> exodus 21  and it will open to the bible book Exodus chapter 21. another test : # <filename> "2 peter" 2 Sample on below screenshoot. Resorces: https://askubuntu.com/questions/423772/can-i-open-a-certain-website-with-a-command-line