Nano: lightweight and flexible text editor

Nano, improved version of Pico, is a friendly, lightweight and flexible text editor, it is ideal to make simple edits. Nano is a modeless text editor (no need to run any command or key combination to start editing the selected file). Once started it shows in the first line: the current version, the name of the file being edited and whether it has been modified or not; then the file in question, in the third line from the bottom up the important messages and in the last 2 lines the most common shortcuts, see figure. The main keys for Nano are: Ctrl (^) and Esc (M), ie with Esc or Ctrl and another key combination we can execute an action. Within its essential features we can mention:

  • Clean interface
  • Low learning curve
  • Internationalization
  • Syntax highlighting for C, C++, Python, Perl, Ruby, HTML, TeX and other
  • Searches / replacement by keywords or regular expressions
  • Forward / back one screen
  • File Explorer
  • Edit multiple files
  • Mouse support
  • Help integrated into the editor
[caption id="attachment_2937" align="aligncenter" width="911"]nano flexible and lightweight text editor nano flexible and lightweight text editor[/caption]

Edition

General syntax

nano [OPCIONES] [+LINE,COLUMN] file

Open the apache2.conf file and go to 20 line, column 23

nano +20,23 /etc/apache2/apache2.conf 

Edit file1.txt

nano file1.txt

Make relevant modifications and

Save the changes

Ctrl o

Nano it will request confirmation on the file that you want to modify, press:

Enter

Copy the current line and store it in the buffer

Esc 6

Cut the current line and store it in the buffer

Ctrl k

Paste what is in the buffer

Ctrl u

Use the mouse to select various lines

Esc a

To copy / cut / paste the selected lines use

Esc 6/Ctrl k/Ctrl u

respectively

Movement

Go to the first line of the file

Esc \

Go to the last line of the file

Esc /

Go to line 10, column 20

Esc g

Nano will request the line and column number to which you want to go, type:

10,20

Go to the beginning of the current line

Ctrl a

Go to the end of the current line

Ctrl e

Moving to matching braces

Esc ]

Advance one screen

Ctrl v

Go back one screen

Ctrl y

Advanced options

Search by keywords

Ctrl w

Search using regular expressions

Ctrl w Esc r

Repeat last search

Esc w

Enable / disable the mouse support

Esc m

Launch integrated help

Ctrl g

Further reading

Nano: lightweight and flexible text editor Read More »

Shell script to rename to lowercase files and directories

GNU/Linux

In the GNU/Linux world, it is common to use lowercase characters to identify files and directories, to illustrate the above we show the DIRs that are found under the /etc/apache2 DIR on Debian GNU/Linux

/etc/apache2/
├── conf-available
├── conf-enabled
├── mods-available
├── mods-enabled
├── sites-available
└── sites-enabled

so if you have one or several DIRs in uppercase or lowercase and uppercase at the same time and for uniformity want to all be lowercase then you can rely on the following script.

[githubget repo=1]sysadmin/shscript/tolower.sh[/githubget]

To use the script download here

Set execute permissions
chmod a+x tolower.sh
Run the script
./tolower.sh nombre-del-fichero

Further readings

  • man find
  • man tr

Shell script to rename to lowercase files and directories Read More »

Create / modify / delete tables in MySQL

One of the frequent tasks during the project development process is the change of the structure of the database. This guide aims to show how to create, modify and delete tables from a MySQL database. However the sentence involved in these operations are extensive and complex and cover all options would be cumbersome and impractical. For more information refer to the official site of MySQL

Create / modify / delete tables in MySQL Read More »

Handle NTFS partitions in GNU/Linux

To handle NTFS partitions in GNU/Linux you should install the package ntfs-3g

Note: From April 2011 the ntfs-3g and ntfsprogs projects joined forces so now everything is in a single suite: ntfs-3g.

Most likely your distribution may already have installed the suite ntfs-3g else you can do it by exec

Debian/Ubuntu

$ sudo apt-get install ntfs-3g

CentOS/Fedora/RHEL

# yum install ntfs-3g

Handle NTFS partitions in GNU/Linux Read More »