Linux for freshers
408 FOLLOWERS
Linux Administration, Interview Question, Tips And Tricks
Linux for freshers
7M ago
This article guides you to resize the EBS volume without rebooting
1. Modify volume in AWS EC2 UI
After login to AWS console, navigate to EC2 -> Elastic Block Store -> Volumes. Click on the volume that you wist to resize, then select Actions -> Modify Volume. It will open a popup.
i) Enter the new size in the size field. Lets says we are resizing from 8 GB to 150 GB.
ii) Click Modify button
iii) Click Yes button in the confirm popup.
Now the volume has been resized, but it won't reflect in the system. We need to do some more steps to make it work.
2. Resize the partition
Let ..read more
Linux for freshers
2y ago
There are some situations where you may need to clear or purge all messages from a queue.
Using Command Line:
You can purge or clear a queue with the following command:
syntax:
$ rabbitmqctl purge_queue queue_name
Purge Queue from the Web UI
Click on the Queues tab.
Click on the name of the queue that you want.
Expand the “Purge” section.
Click the “Purge Messages” button.
Click “OK”.
Purging all queues
$ rabbitmqadmin -f tsv -q list queues name > list1.txt
$ for i in `cat list1.txt`; do rabbitmqctl purge_queue "$i" ; done  ..read more
Linux for freshers
3y ago
What is XAMPP?
XAMPP is the most popular PHP development environment.
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl.
Download the latest version from here
wget https://www.apachefriends.org/xampp-files/7.4.16/xampp-linux-x64-7.4.16-0-installer.run
After download change the permission :
chmod 755 xampp-linux-x64-7.4.16-0-installer.run
sudo ./xampp-linux-x64-7.4.16-0-installer.run
If it linux server Press all Yes during installation.
If it is the desktop version of linux press next during installation.
Now need to c ..read more
Linux for freshers
3y ago
Wall displays the contents of a file or, by default, its standard input, on the terminals of all currently logged-in users. The command will cut over 79 character long lines to new lines. Short lines are white space padded to have 79 characters. The command will always put the carriage return and new line at the end of each line.
Only the super-user can write on the terminals of users who have chosen to deny messages or are using a program that automatically denies messages.
Reading from a file is refused when the invoker is not a superuser and the program is suid or sgid.
Usually, sy ..read more
Linux for freshers
3y ago
In ubuntu By default python version was 2.7. We need to use python3 to run the python files with the latest version.
Steps to change the default python version to 3
Check the current version
#python --version
Python 2.7.17
Execute this command to switch to python 3.6.
#sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Output:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
Check python version
python --version
Python 3.6 ..read more
Linux for freshers
3y ago
Innotop is an efficient command-line monitoring tool for local and remote MySQL servers running under Innodb. It helps to monitoring several operations like MySQL replication status, user statistics, query list, InnoDB buffers, InnoDB I/O information etc.
To Install Innotop
Run the following command to install Innotop
In RedHat
yum install innotop
In Ubuntu
Fetch innotop from its GIT repository:
Install Perl dependency:
sudo apt install libterm-readkey-perl libclass-dbi-perl libclass-dbi-mysql-perl make
sudo apt-get install git
git clone https://github.com/innotop/innotop.git ..read more
Linux for freshers
3y ago
There are times when you need to know the file size of an HTTP object without actually downloading the file. This little trick comes in very handy when web servers respond with the Content-Length of an object in the HEAD request itself.
Using curl command:
Example:
curl -sI https://releases.ubuntu.com/20.04.2.0/ubuntu-20.04.2.0-desktop-amd64.iso | grep Content-Length
Content-Length: 2877227008
Let’s try and make this human-friendly:
curl -sI https://releases.ubuntu.com/20.04.2.0/ubuntu-20.04.2.0-desktop-amd64.iso | grep Content-Length | sed 's/[^0-9]//g' | numfmt --to=si
2.9G
Where Th ..read more
Linux for freshers
3y ago
#!/bin/bash -x
if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
if [ -f /usr/bin/mkpasswd ]; then
pass=$(mkpasswd -m sha-512 $password)
#mkpasswd will create encrypted password.
useradd -m -p "$pass" "$username"
[ $? -eq 0 ] && echo "User has been added to system!" && chage -d0 $username || echo "Failed to add a user!"
else
echo "install package apt-get install whois"
f ..read more
Linux for freshers
3y ago
how to check If the file Is Empty or not using shell script?
-s FILE
FILE exists and has a size greater than zero
Example 1:
touch /$HOME/f1
echo "data" >/$HOME/f2
ls -l /$HOME/f{1,2}
[ -s /$HOME/f1 ]
echo $?
Sample outputs:
1
The non-zero output indicates that the file is empty.
[ -s /$HOME/f2 ]
echo $?
Sample outputs:
0
$? is the return code of the last executed command.
Example 2:
$ ls
$ touch file_1
$ dd if=/dev/zero of=$HOME/file_2 bs=1 count=100
100+0 records in
100+0 records o ..read more
Linux for freshers
3y ago
Input/Output Error : Bad Blocks - How to Reboot or shutdown the Linux server?
Input/output error while running the command mostly due to it could be bad blocks on the disk.
In this situation, first suggestion would be to check /var/log/messages for any disk-related alerts (might see some sense key alerts).
tail -n 100 /var/log/messages or tail -n 100 /var/log/syslog
tail -f /var/log/messages
#du
bash: /usr/bin/du: Input/output error
Now if try to reboot,it can also give the same output. You can try to init 6.
# reboot or init 6
bash: /sbin/reboot: Input/output e ..read more