Showing posts with label command prompt. Show all posts
Showing posts with label command prompt. Show all posts

Sunday, June 17, 2012

Living in the Command Line

Some people, usually extreme power users, server owners, and hobbyists choose to use the command line as their primary means of communicating with their computer. Richard Stallman has said that he finds that graphics "distract" him. The command line's learning curve is high since you must know about the command you are issuing, and because a lot of applications are now being developed with their front AND backends using GTK or QT. This article will teach you how to block everything else out, and use the command line for daily life.

Tty's
Tty's are separate logins. You may not know it, but you have 7 open right now if you are using a Linux box. To enter a tty, do this: alt+ctrl+a number 1-6. When you do alt+ctrl+7 from any tty, you will re-enter graphics. Some prefer to use a tty instead of a terminal. Each has a login prompt, where you enter your user name. Then, your password. Don't be surprised if your num lock key is turned off or if you do not see the characters of a pssword being typed. It does this for your safety.

Now that you are in a tty, there are a few things to learn about everyday usage.

Editing Text
To edit text from the command line, you can use GNU Emacs or VIM if either are installed. Otherwise, you will have to use vi, which is usually installed by default on any distribution. Each of the programs have different commands that they use. This can also be used to edit music, movies, and pictures.

Browsing the internet
yes, you can browse the internet from the command line! Download nad install something called links2, which is a textual web browser. From the command line, use the commnad links www.website.com. In links2, you can hit "g" on a non-input area to go to a different website. Sites like Google will work correctly. However, some that use Flash and some that use Javascript will not. Of course, no pictures will be available in this way.

Watching Movies
Wait, you can watch movies from the command line? Yes! You can watch movies in the command line. Download and install mplayer2 (sudo apt-get install mplayer2), then use (mplayer /home/user/movie). This will use the ncurses library to make colored letters to let you watch your video. On X, you can use this and it will create a window to show it in.

Send Email
http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/
This works for some people, but my ISP doesn't allow this to happen. Instead, I have to use smtp, which is a bit harder.
http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/
That explains this in-depth.

Move files
cd changes your directory. ls lists directories. mv moves a file. You can also rename files with mv. To make files, use mkdir. To remove them, use rm.

Kill Processes
Sometimes a process will run long in a tty. When this happens, log into another tty and issue ps -aux
This will list processes and ID's. Then, you can use (kill (ID NUMBER)) (Example: kill 23)

KILL, KILL, KILL
This is a very popular way to remove everything on your computer. Do NOT fall for this anywhere where it may tell you.
sudo rm -rf /
Do not use this command unless you absolutely want to


Tips
man describes a program.
The tab key will autocomplete a statement. I cannot put enough emphasize on how useful this is.

http://www.ubuntugeek.com/useful-and-fun-things-to-do-with-the-ubuntu-terminal.html
This website houses a bunch of cool information.

Sunday, March 25, 2012

10 must-have programs for gnu/linux

I have used GNU/Linux for over a year on various distributions. I have done everything from edit text, programming, gaming, emulating, and modifying the look and feel of the desktop environment. To do so, I used a variety of useful tools which I will list below.

1 - GNU C Compiler

The GNU C Compiler, or GCC for short, allows you to compile programs written in the C programming language with gcc and C++ programming languages with g++. Non-programmers will also benefit from having gcc on their system, since a lot of the software mentioned will not come in a compiled package, so you must do it yourself.

sudo apt/yum/equo install gcc

2 - Firefox

Although not specific to gnu/linux, firefox is arguably the best web browser available. Firefox is free and open source, so anybody can edit and modify it to their needs. Firefox is also built on top of the second best plugin framework around (first being Eclipse), so it is highly extensible.

sudo apt/yum/equo install firefox

3 - Terminator

sudo apt/yum/equo install terminator

On most distros, xterm is the default terminal emulator. Terminator is a new terminal emulator with much added functionality, such as terminal groups and broadcasting.

4 - The Libreoffice suite

The Libreoffice suite can be seen as the open-source version of the Microsoft office suite, allowing the user to create presentations, documents, spreadsheets, databases, and drawings. Downloads are available at their website.

www.libreoffice.com

5 -  zsh

Zsh, the Z-shell, is a replacement for BASH, the shell that is commonly found on Linux systems. Zsh brings multiple improvements to batch, especially with its advanced tab completion. Some of the attractions to zsh are its portability (since it doesn't rely on external programs), its backwards-compatibility with BASH, and the way it handles tab completion.

sudo apt/yum/equo install zsh

6 - GIMP

GIMP, the GNU Image Manipulation Program, is a photo editing program much like Photoshop. A debate continues to this day over which is better, but the fact that there is even question over which is superior is a telltale sign of GIMP's functionality. In the next major release, GIMP will become much easier to use and add additional features. That version of GIMP is available on Github right now.

sudo apt/yum/equo install gimp

7 - Avast Antivirus

Avast offers a free (gratis) antivirus program that can scan Linux systems for viruses. Although Linux is a very secure operating system, it has it's security holes. The primary usage for avast isn't for scanning your own system, but for scanning files you are planning on giving to another person.

www.avast.com

8 - vim

Vim is a text editor that runs from the command line. It is a vast improvement over its predecessor, vi, in multiple ways. It supports plugins, has syntax highlighting right out of the box, and has a more logical (and less painful) command system than emacs.

sudo apt/yum/equo install vim

8 - tint2

This program may seem trivial, but if you are using another dock such as gnome-panel or cairo-dock you may want to check this out. I used to use docky, but it was heavyweight and requires composting. Tint2, in contrast, is lightweight, simple, and attractive. It could also save you some time. Right clicking on a window will close it instead of bringing up a menu.

sudo apt/yum/equo install tint2


9 - mplayer2

Whenever I'm not doing something that requires too much concentration, I listen to music. Although, I found myself wondering why I needed a GUI to do so. mplayer2 allows you to play music and watch videos from the command line. It also supports playlists and streaming.

sudo apt/yum/equo install mplayer2 


10 - Links2

While we're still on the theme of command line applications, I must mention links2. Links2 is an improvement over links and lynx, and allows the browsing of the web through the command line. In addition to browsing, links can also handle the downloading of files. With links2 there is also an extremely fast, graphical browser that supports pictures.

sudo apt/yum/equo install links2

There are programs  I have not mentioned that I use every day, such as picasa and code::blocks, but I did not mention them since they wouldn't appeal to everybody.



 

 

Saturday, December 24, 2011

Bash Lesson one - Learn the Linux command line

Bourne Again SHell, or Bash, is the shell most commonly used on Linux systems. Bash can be installed on Windows, BSD, and other variants of Unix. Most of the functionality that Bash provides really isn't bash at all, but external programs. Some examples are sudo, vi, emacs, and espeak, just to name a few. To complete this lesson you will need either vi or emacs and sudo. Vi is run from the command line like emacs, but emacs also has a graphical mode that will boot when you launch it from a terminal. Make sure that you are in the sudoers file.

Let's get started. Open up a new terminal (xterm, terminator, yakakua, etc) and type "cd /" and press enter. Cd changes directory, so you just moved from home (or whatever location you booted the terminal from) to the root directory. Now, without the next command cd isn't much good since you would be flying blind. Type "ls". This will show you everything in your current folder in a color coded fashion.

Now, we are going to try something a bit more difficult. While in this directory type "cd bin" and press enter. You can type ls in here if you want, but be prepared because this is a huge folder. While in this folder type "sudo vi "myScript.sh"" Be sure to include the quotes even though they are not needed.

This will open Vim, VI improved.Hit i on the keyboard to enter the text insertion mode. Now type the following in the file just like I have it structured.
#! /bin/bash
cd /
mkdir success
I will explain mkdir a bit later. To save the file from vi hit the escape button once followed by a capital 'Z' twice. (ex: [esc] ZZ.)This will close vi and save the file. If you were choosing to use emacs you can go to file>save or use the command C-x C-s. Now you should be back at the command prompt. This is probably the step that gets messed up the most. Now type "chmod +x myScript.sh" This just makes the shell script (which is what you made) executable.

We are now ready to run the script, but what do you think it will do? The two commands in it were cd / which you already know and mkdir success. What this does is changes directory to root and makes a directory called success.

To test this out, type "sudo myScript.sh". Running it with administrative privileges is a must because of where it makes the folder. Now, type "cd /" again and "ls". If you have done everything correctly you should see blue letters that say "success" on them.

BASH gets much more confusing than this, but for now it's a good start.




The same exercise as a non-root user
This is the same exercise from above but I will use your home directory instead. If you have already read parts of it, you can skip over right to the commands.


Let's get started. Open up a new terminal (xterm, terminator, yakakua, etc) and type "cd" and press enter. Cd changes directory, so you just moved from home (or whatever location you booted the terminal from) to the home directory. That is useful if you get lost and need to get back to a checkpoint. Now, without the next command cd isn't much good since you would be flying blind. Type "ls". This will show you everything in your current folder in a color coded fashion.

Now, we are going to try something a bit more difficult. While in this folder type "sudo vi "myScript.sh"" Be sure to include the quotes even though they are not needed.


This will open Vim, VI improved.Hit i on the keyboard to enter the text insertion mode. Now type the following in the file just like I have it structured.
#! /bin/bash
cd
mkdir success
I will explain mkdir a bit later. To save the file from vi hit the escape button once followed by a capital 'Z' twice. (ex: [esc] ZZ.)This will close vi and save the file. If you were choosing to use emacs you can go to file>save or use the command C-x C-s. Now you should be back at the command prompt. This is probably the step that gets messed up the most. Now type "chmod +x myScript.sh" This just makes the shell script (which is what you made) executable.


We are now ready to run the script, but what do you think it will do? The two commands in it were cd which you already know and mkdir success. What this does is changes directory to home and makes a directory called success.


To test this out, type "myScript.sh". Now, type "cd" again and "ls". If you have done everything correctly you should see blue letters that say "success" on them.

Sunday, March 13, 2011

Windows cmd lesson 1 - The basics

Cmd, or command prompt, is the shell of the Windows Operating system. It is here where you can tell your computer to execute commands in the simplest way possible; text commands. There's no fancy user interface to tell it what to do. Just a black screen with white text.

 To run cmd on Windows 7 type "cmd" into the search box and hit enter. It will run automatically. On earlier versions of windows you will have to use Run and then type cmd+enter. You will be greeted with C:/Users/user: | This is where you can tell cmd what actions you want done. If you are not happy with the color setup you can type COLOR (Numbers 1-100 or letters) to change the color. Color 3 and Color a are both greens. Color A than color 3.
Once you have your color scheme arranged it is time to tell it to start doing commands. You could start off simple by finding out your IP address with Ipconfig. Another useful command is Tracert followed by an IP address or a URL. This will show how many hops (steps) it takes to reach a destination on the web from your current location. This will count for a maximum of 30 hops unless you type -h (number) after the tracert commands. This will tell cmd exactly how many hops you want to set as a maximum. -w  (number) will tell it how long to wait before it considers the connection "time out" or lost. If you have a slow connection speed this will be your best bet.

The next and most widely used command on cmd is
Ping. By default Ping sends a request for 32 bytes of data to a server and waits for it to send the 32 bytes back. It will do this a default of 4 times before telling you your highest, average, and lowest connection speed in milliseconds. This is a good tool for testing internet connection speed against a server or to see if an internet connection problem originated from your connection or your website. Another (illegal) use for this is attacking a website with massive ping requests in an attempt to slow it down. This can be done using the commands -t (makes the ping process go until it is interrupted) and -l (number of bytes after -l). The higher the number of bytes the higher amount of work the server has to do. There is a cap of 64,000 bytes, but most computers can't handle that with the default timeout time. Once again, typing -w (time) will allow you to reset that amount.
The last commands are Cls and Title. CLS just clears the cmd screen from all previous text. Title (followed by text) is what the name of the cmd window will be. So for instance if you wrote Title The legionnaire's den. the title of the cmd window would change from cmd.exe to "The Legionnaire's Den.".