Debian Work Environment

Valic —  June 10, 2013 — Leave a comment

You found out in a previous article that Midnight Commander allows you to do almost everything under Debian, but it is very important for you to become familiar with the work environment and to learn how to use the command line tools from the shell prompt. You are able to select your login shell using chsh. The list of shell programs may include: bash, tcsh, dash, zsh, pdksh, csh, sash, ksh, rc or posh. In this article we will use bash as the interactive shell. The bash behaviour can be customized from “~/.bashrc“. Under Debian work environment there are some key strokes, special ones, which have a special meaning, as you can see in the below list:

  • Ctrl-U will erase the line before cursor
  • Ctrl-H is used to erase one character before cursor
  • Ctrl-D will terminate exit shell
  • Ctrl-C used to terminate a running program
  • Ctrl-Z stops the program temporarily
  • Ctrl-S used for halt output to screen
  • Ctrl-Q will reactivate the output to screen

Mouse can be also used, and these operations are made using a 3 button mouse. Button functions are not different that a standard one. Please note that in order to use a mouse on a Linux console you must have gpm(8) as a daemon running. An enhanced pager, less(1), exists on this work environment. If you have not defined yet a default text editor under your Debian operating system, you will have to install one. VIM is recommended by most users. The default editor is located at ‘/usr/bin/editor‘ and can be properly invoked by other applications. Before installing one editor, please check what values you have for environment variables “$VISUAL” or “$EDITOR” and see what editor are you currently using.

If you need a mode to record the activities you make while using the shell prompt, in order not to lose forever what you wrote there or if you need to do a review of them sometime in the future (especially for those of you who are doing administrative tasks), this is the way to do it: type ‘script‘ in command line, make your commands, press ‘Ctrl + D’ to exit the script and then write ‘vim typescript’ which will show you the entire script history.

Now you are at that moment when you will have to learn some basic Debian commands in the editor. Execute the below command while logged in with a non privileged user:

  • pwd is used to display the name of the working directory
  • whoami will display the current username
  • id displays the current user identity
  • file <x> will display a type of file for the file “<x >”
  • ls lists the content of a directory
  • ls -a lists the contents of a directory but including all files and directories
  • mkdir x – make a new directory x
  • rmdir x – removes a directory x
  • top will display the current process information using full screen mode Continue Reading…
Commander may sound familiar for you. GNU Midnight Commander, or MC, is a clone from Norton Commander and a free cross platform file manager licensed under the terms of the GNU License. It has a text user interface, being a console application. It includes 2 panels meant to display the system of files. You can move to files using arrow keys, you are able to select one file using the Insert key and some Function keys are for operations like editing, renaming or copying files. Some advanced versions of Midnight Commander have support for mouse.

If you didn’t knew, the term of Midnight Commander comes from a Swiss army knife. It is excellent for a newbie in Debian because it gives you a menu driven console experience which you will find very easy to learn, especially standard Debian commands. If you want to install the Midnight Commander package, called ‘mc’, you will have to run the command ‘ apt-get install mc‘.

If you need to explore the Debian file system the command is mc. Now you have it there, here are some cool locations you can explore using direction keys and Enter key:

  • “/etc” and subdirectories
  • /usr/share/doc” and subdirectories
  • /var/log” and subdirectories
  • /bin” and “/sbin

The default package comes without any customizations. If you need some changes, these can be made modifying the “~/.bashrc” which has to include a script provided in the package. You can start the MC using the command ‘mc’. Your effort will be minimal since all operations are made using the included menu. F1 is the best way to start, in order to see the help screen and check some useful stuff there. If encoding characters are an issue for you, just including an ‘-a’ to your command in MC will make these problems disappear.

File manager in Midnight Commander

It includes two panels which lists the files. Many users set the right panel to display information regarding permissions, for example, which you may find it to be useful sometimes. Here are some keystrokes very important when you use the MC under Debian:

  • F1 opens the help menu
  • F3 displays the internal file viewer
  • F4 opens an internal editor
  • F9 to activate pull down menu
  • F10 will exit from Midnight Commander
  • Tab helps you move between two windows
  • Insert or Ctrl-T is used to mark the file for a multiple-file operation such as copy or rename
  • Del is used to delete the file (set MC to safe delete mode)
  • Cursor keys –  move through file system

Also, if you want to know some tricks for command line, here are some of them – ‘cd’ command will change the directory, ‘Ctrl + Enter’ will copy a file name to the command line, shell file name expansion choices can be seen using ‘Alt + Tab’, ‘Esc + 1’ has the effect of F1 and pressing ‘Esc’ before pressing another key is like pressing Alt + that key.

This is just a starter article, more to come soon. Please use the above information along with Debian documentation and Midnight Commander will become easier for you. Continue Reading…

Debian file system

Valic —  May 27, 2013 — Leave a comment

What is a file system?

A file system represents a collection of files stored in a specific way on a system. There are many ways to keep files and, as you probably already know, there are also many file systems types. Each type will describe a uniform method meant to store files on a storage medium. Think about this as a hard disk partition. If this storage will be different it would be very difficult for you to share these files with other people.

All directories and files are kept into a high tree rooted at ‘/’. This is like a tree because if the file system would be drawn it will be like a tree upside down. These can be spread out over more devices and you can attach the file system using mount(8).

On Debian system the folders are called directories. There is no drive concept (such as “A:”). You have only one file system where all you need is included. Compared to windows you will find this to be a great advantage.

Here are some basic details regarding the file system on Debian operating system:

  • You will have to use case sensitive mode for all files, ‘FILE’ and ‘file’ are completely different documents
  • When you refer to root directory it means you talk about the root of the file system: ‘/’. This is different from the home directory for the root user: ‘/root’.
  • You can use for your file and directory names any symbol or letter. The only character you cannot use is ‘/’, this being a representation for the root directory
  • The root directory filename (/) cannot be renamed
  • All directories and files are designated by a path or an absolute filename, which will show the full sequence which needs to be passed in order to reach to that specific file
  • Several branches can be found in the root directory: ‘/etc/’ or ‘/usr/’. These have also other branches, such as ‘/etc/init.d/’ or ‘/usr/local/’.
  • There is no specific path having a correspondent to a physical device
  • You can find more information about this in the file system hierarchy standard

Here you can find some key directories and their specific usage:

  • 1. / – this is the root directory
  • 2. /etc/ – this is the place for the configuration files
  • 3. /var/log/ – find system log files here
  • 4. /home/ – home directories

Next, each file has its own permissions. Read permission will allow the user to read the content of a file. Write permission will allow the user to change the content of that file. Execute permission will allow the user to execute that file as a command. Using the command ‘ls(1)’ you will be able to see the permission information for the files and directories and when it is invoked with “-1” it will display more information such as file type, number of hard links to that file, owner username, its group or size.

We hope this starter material for Debian file system will help you get a basic overview meant to help you in the future. Continue Reading…

Maybe you are new to this operating system or maybe you already know the Debian basics. When you learn a new computer operating system you feel like learning a new language, not your native, but a foreign one. You may use tutorials, books, documentation, these are very helpful, but without any practice it may be useless. In order to offer you some help we elaborated some basic points regarding the Debian console basics which you may consider useful information, especially if you are getting started now.

First of all, let’s start with the shell prompt. After you login you will be able to use Debian shell prompt, also known as command prompt, which will be displayed in the left side of your monitor. What is its purpose? Well, for the moment it is waiting for you to write some commands there. The welcome message for the shell prompt can be easily customized if you edit the file ‘etc/modt.tail’. So, you are in the shell which will compile your future commands.

You may have installed the X Window System with Gnome (a display manager) you will see the graphic screen at logon. You are logged in now, and if you made this with a super-user or the root account you can do some pretty cool administrative tasks: remove, write and read any file on the system, no matter what their permissions are, set file permissions and ownerships, set passwords for other users on your Debian system or, check this out, you can login to any other account without even knowing the password they use. As you can see there is nothing you cannot do if you are the root user. Be responsible while using this account and never share your password with other people. Stay safe!

If you want to get to the root shell prompt using the root password you can acquire this by:

  • typing ‘root‘ when you are in the basic command prompt
  • typing ‘su -1‘ from any user shell prompt (you will lose your current data)
  • typing ‘su‘ from any shell prompt (keeping some of your current data)

If you finished your job on the current session you can leave the command prompt in Debian typing the keys ‘CTRL + D‘, pressed together, and your shell activity will be done. If you are in the character console this command will get you back to the shell prompt. Other way to leave the prompt is to type ‘exit’ at the command line. When your job is finished and you want to shut down the system from the command line using ‘shutdown -h now’. Instead, if you want to recover a console (maybe after your screen went berserk) you can write ‘reset’ on the shell prompt on Debian.

You are now able to use the Debian operating system without any risk, but make sure to read also the Security Manual from Debian documentation, because you have to use a non privileged user account to stay safe. Of course, you will have to go deep with the shell prompt, but this article offered you an overview which will be helpful for you in the future.

Debian is an operating system which includes software packages released as open source software for free, mainly under the GNU General Public License but also with other free software licenses. It runs a popular Linux distribution having access to repositories including software packages which are ready for use. In this article you will learn how to process texts using Debian. We assume that you already know how to create simple text documents using an editor, such as v1, for example. Let’s go, then.

What does text processing means?

It allows you to write the content of a file as an ASCII text using some additional commands in order to describe better your document structure. By starting the text processor you will be able to convert the source text to a file with a layout. This file can include some tables, formulas or figures, for example. At this moment some of the most used and known text processors for Debian are LaTeX and TeX.

LaTeX is a strong macro package used for TeX typesetting system. There are some text processing tools used by most users which make this by piping text through chains. When no regular expression is used you can concatenate files and output the resulted content using the cat(1) command or, in the other direction you can use tac(1) to output a reversed content. Use cut(1) to select parts of lines, sort(1) in order to sort lines from content or tr(1) if you want to delete characters or translate content.

On the other hand you are able, using some basic regular expressions (BRE), to match some text with some patterns – using grep(1) – or to power a screen editor using the command vim(1). Other extended regular expressions (ERE) will make possible for you to do simple text processing by using egrep(1).

If you are not familiar with these commands you can figure this out very easily using the command man command’. Below you can find a list with useful commands for standard text processing on Debian:

  • When no regular expression is used: cat(1), tac(1), diff(1), tr(1), cut(1), head(1), uniq(1), tail(1), sort(1)
  • When basic regular expressions are used: grep(1), emacs(1), ed(1), vim(1), sed(1)
  • When extended regular expressions are used: egrep(1), python(1), awk(1), pcregrep(1), tcl(3tcl), perl(1)

You can use regular expressions for many tools for text processing. Think about them as shell globs but obviously more complex and powerful. These expressions are formed by meta characters and text characters and they describe usually matching patterns. The meta characters are just simple characters having special meanings. Replacement expressions are some characters having also special meanings.

This was only an introduction article in this area, this overview being only the beginning for what is about to come. We hope that these tips regarding text processing in Debian operating system will help you make an idea about how this works and future documentation will be always available on in order to help you move on with your needs. Continue Reading…