Monday, February 7, 2022

How to Install ranger in Ubuntu 18.04?

How to Install ranger in Ubuntu 18.04?



ranger - visual file manager


Ranger is a free and open-source command-line file manager for Linux. It comes with a minimalistic text-based user interface and VI key bindings support. The main design goal of this file manager is switch directories and browse files in a quick and easy way. Some of the main features are preview the selected file or directory and automatically determining file types and running them with correct programs. It supports VIM like hotkeys, UTF-8, multi-column display, mouse support, builds in Tabs, and bookmarks support.



Features of Ranger

  • Multi-column display

  • Common file operations (create/chmod/copy/delete)

  • Preview of the selected file/directory

  • VIM-like console and hotkeys

  • A quick way to switch directories and browse the file system

  • Tabs, Bookmarks, Mouse support

  • Video thumbnails previews



Install Ranger File Manager on Ubuntu


sudo apt-get update


sudo apt install ranger -y


Type command 

ranger




To change directories, you can use the arrow keys: Press Right to go into the currently selected directory, or Left to go into the parent directory. Similarly to select items in the middle panel, use the Up and Down arrow keys. There are number of commands you can use to perform different operations on the files but here are some of the most common commands.


For navigation


  • <Ctrl>-f = Page down

  • <Ctrl>-b = Page up

  • gg = Go to the top of the list

  • G = Go to the bottom of the list

  • H = Go back through navigation history

  • h = Move to parent directory

  • J = Page down 1/2 page

  • J = Move down

  • K = Page up 1/2 page

  • k = Move up

  • L = Go forward through navigation history

  • Q = Quit

Working with files


  • i … Display the file

  • E|I … Edit the file

  • r … Open file with the chosen program

  • cw … Rename file

  • / … Search for files (n|p jump to next/previous match)

  • dd .. Mark file for cut

  • ud … Uncut

  • p … Paste file

  • yy .. Copy/yank file

  • zh … Show hidden files

  • <space> = Select current file

  • :delete = Delete selected file

  • :mkdir … Create a directory

  •  :touch … Create a file

  •  :rename … Rename file



For More options use

man  ranger

 

Thursday, December 23, 2021

RabbitMQ How to Purge All Queues ?

 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 




Tuesday, April 27, 2021

How to Install XAMPP on linux ?

 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 change the permission for htdocs :


cd /opt/lampp/



chmod -R 777 htdocs


cd htdocs


create one demo.php file and write code :


<?php

echo “Welcome to linux for freshers” 

?>


To start the XAMPP service :


sudo /opt/lampp/lampp start


Starting XAMPP for Linux 7.4.16-0...

XAMPP: Starting Apache...ok.

XAMPP: Starting MySQL...ok.

XAMPP: Starting ProFTPD...ok.




To run the php file:

http://localhost/demo.php


Or 


http://lip_address/demo.php




To stop the XAMPP service:


sudo /opt/lampp/lampp stop


Stopping XAMPP for Linux 7.4.16-0...

XAMPP: Stopping Apache...ok.

XAMPP: Stopping MySQL...ok.

XAMPP: Stopping ProFTPD...ok.



Friday, April 23, 2021

how to send broadcast messages to all currently logged on users in linux ?

 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, system administrators send messages to announce maintenance and ask users to log out and close all open programs. The messages are shown to all logged-in users with a terminal open.


Syntax:


wall [-n] [-t timeout] [message | file]




The most straightforward way to broadcast a message is to invoke the wall command with the message as the argument:


Example: 


wall "The system will be restarted in 10 minutes."


Output:


Broadcast message fromroot@linuxforfreshers (pts/0) (Mon Jan  4 13:22:07 2021):


The system will be restarted in 10 minutes.


The message will be broadcasted to all users that are currently logged in.



To suppress the banner and show only the text you types to the logged-in users, invoke the command with the -n (--nobanner) option:


Example: 


wall -n "The system will be restarted in 10 minutes."


Output: 

The system will be restarted in 10 minutes.




If you want to write multi-line messages, invoke the command without an argument:


wall


The wall command will wait for you to enter text. When you’re done typing the message, press Ctrl+D to end the program and broadcast the message.



You can also use the here-string redirection or pipe the output of another command to wall. Here is an example showing how to use the echo command to broadcast multi-line messages:


Example:


echo "The system will be restarted in 10 minutes. \nPlease save your work."  | wall


Output:


Broadcast Message from root@linuxforfreshers                                       

        (/dev/pts/1) at 13:36 ...                                              

                                                                               

The system will be restarted in 10 minutes. \nPlease save your work.        


Broadcasting a Message From a File 


If you are regularly sending the same messages, you can write each one of them to a file, so that you don’t need to re-type the same text. wall reads from the file only when invoked as root.


To broadcast the contents of a file, invoke the wall command followed by the file name:


cat message1_file.txt

The system will be restarted in 10 minutes.


Example:


wall message1_file.txt


OUTPUT:


Broadcast message from root@linuxforfreshers (pts/0) (Mon Jan  4 13:30:07 2021):


The system will be restarted in 10 minutes.


Thursday, April 8, 2021

How to change python default version in ubuntu?

 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.9