Linux.com

Community Blogs



Simple scripting to save your Wifi connection

Wireless device support and stability have come a long way in Linux since i started using Ubuntu a few years ago.

Now and again though, something can happen to make you lose your wireless connection.  Many people solve this by restarting network manager or by simply restarting the computer.  

With a small script file, you can restart your wireless driver when its on the fritz, quicly and easily.

First create a file: 

gksudo gedit /usr/local/bin/name-of-file

Then add the script code:

#!/bin/bash

modprobe -r your-wireless-device
modprobe your-wireless-device

Save and close your file and give permissions to run it:

sudo chmod +x /usr/local/bin/name-of-file

Finall, run the script by typing in the terminal:

sudo name-of-file

 

Hope this helps some people, not only with keeping you wifi going strong, but also with how to implement simple scripts to make computing easier and funner.

 

-GL

 

 

Excellent Beginning Python Series on LinuxPlanet

Hey all,

I wish to shamelessly plug a series of excellent Python articles on LinuxPlanet. Akkana Peck, ace coder and all-around cool person, has been writing a series of howtos for Python beginners.  Python is a great language for anyone wanting to learn to code; it has a nice clean syntax, an orderly structure, and because it's an interpreted language you don't have to mess with compiling and linking and all those fun things. Which are fun, after you get a grounding in a nice interpreted language like Python.

Intro to Shell Programming: Writing a Simple Web Gallery
GUI Programming in Python For Beginners: Create a Timer in 30 Minutes
Graphical Python Programming With PyGTK

Enjoy, and thanks for reading!

 

Buying or Building - System Options

I'm probably slightly older than the average member here at Linux.com at 47 years of age. I was an early... and a late comer to computers. How could I be both? Well, it's a long story. Go grab that cup of coffee you wanted. I'll wait for you to get back...

My actual career, which no longer exists in the U.S., was RF communication (radio) and audio repair specialist. I was something you may have heard your dad talk about... a component level bench technician. I did this for about twenty years. Then one day I woke up and my job had moved to Korea, then on to China, eventually.

Back in the late 70s and early 80s I was in college learning about microprocessors and machine language. Some of you older folks might remember the 8080A, 8085, and the Z80 processors. They were the bleeding edge of the technology at that time. Nowadays, they're used to control sprinkler timer systems to keep your neighbor's grass pretty and green.

My first experience with what you might call a modern computer was the Commodore Vic 20. It was a pretty amazing machine at the time. Shortly after that I acquired a Commodore SX-64 briefcase computer system. This thing was the cat's meow. Let me tell you! It had a built-in 5¼" floppy, a game slot, and a 5" color monitor. With 64K, you were rockin' and rollin'. Here's what one looked like:

It has a 300 Baud modem that I used to access Compuserve and some local BBS (electronic bulletin boards). Lotsa' fun! I wasted hours with this thing online or playing text-based adventure games like Infocom's Zork series. Shortly after this time (early 80s), I moved on in life and left the computer in the closet collecting dust. 

One day in '93, I was at my brother's office. He showed me his new system. It was a 486 DX-66 running a new operating system called Windows. Cool! This thing was amazing compared to my old Commodore. Time went on by... Early in 2000, my brother asked my advice about purchasing a new personal computer system. He knew I had friends who were big muckity-mucks locally for the Gateway store. I set my brother up with them. He got a nice new system.

He called me a few days later and asked if I'd like his old system. He knew that I didn't have a computer. At this time, I had just started flirting around with the World Wide Web and USENET using a friend's system or the one at the public library. I told my brother that I would definitely like that old system. I went over to his place and picked it up right away.

It was a Pentium I 90 with a 2Gig hard drive and 64M RAM. It was running Windows 98SE. With that little system, I entered what was to me the modern computer age. This Windows stuff was pretty cool! Oops! What's this blue screen error notice I get once or twice a day?

Hey! This is frustrating!  Heh-heh. Ah... the memories.

Anyway, that's when I became a serious USENET/boards/forums junkie. To me the Internet is about two things: knowledge and community. I've spent the last nine years partaking of both. So, getting to the point of this entire, long-winded posting... is it better to buy or build your own systems?

For me, with my technical experience, it's much better to build I can build a very customized, top-of-the-line machine for about a third of what it would cost me to buy one. That's how the ericsbane series started. I built ericsbane01 with an AMD K7 Thunderbird CPU. I built ericsbane02 with an AMD Athlon 2600+. And I built my current ericsbane03 with an AMD Athlon XP-64 3800+. Yeah, I kinda' like AMD processors.

Building your own system is not for everyone, but it's really not that difficult. Do your research. Price your hardware and peripherals. Put it all together. Install your favorite GNU/Linux distro and you're all set.

Until next time...

V. T. Eric Layton

***Tempus Fugits***

   

Pensamientos sobre el desarrollo de Linux

 Hoy quisiera compartirles algunos pensamientos sobre este fenómenal sistema operativo.

Linux ha logrado tener un lugar en el mundo informático, a veces lo vemos como algo normal dentro del mundo actual, pero su crecimiento no deja de ser fantástico.

Hoy en día grandes empresas están respaldando soluciones basadas en Linux. A nivel internacional y también a nivel regional la penetración de Linux es imparable.

Vivo en la ciudad de Torreón en México. Es una de las principales 20 ciudades del país, y veo con admiración y personal satisfacción la penetración que lleva Linux dentro de las grandes empresas regionales.

Se ha vuelto una herramienta que a las empresas comienzan a ver natural. Día a día es más difícil ver una empresa grande sin que tenga en su arsenal servidores Linux.

EN el plano internacional es todavía mayor el efecto. El compromiso de un gigante como IBM con el software libre era una fantasía hace unos años; y sin embargo, hoy es una realidad. Empresas que deciden empujar sus economías de la mano del software libre.

Estamos viviendo uno de los mejores momentos de la comunidad. Particularmente en el área empresarial.  

SIento que es un efecto natural debido a la comunidad. Gente con gran ingenio técnico y una preparación en sistemas son quienes soportan actualmente este fenómeno. La exigencia es que los sistemas sean robustos y funcionales, y estos valores son bienvenidos en las empresas. 

Conscientemente estoy dejando de lado el ambiente de escritorio, dejándolo intencionalmente para otro artículo.  

 Disfrutemos de este periodo, pues haciéndolo contribuimos a que siga adelante nuestro querido sistema operativo.

 

Japanese popular gathering "Benkyoukai"

日本では今IT業界だけではなく勉強会が盛んだ。

特定の分野に興味がある人が集まって一緒に勉強する。

People get to gether and study common interest thing.

私も今日は勉強会だった。今日のタイトルは仮想マシーン(VMM)

I attended "Benkyoukai" today. Today's focus is VMM, Virtualization.

欧米ではこんな集まりはあるのだろうか。英語ではなんて言えば通じるのだろうか?

Do people in western contories have this kind of gathering. If so, how can I say that kind of gathering?

 

でも日本独自?だとしたら日本人の勤勉さの証明?

 

 

Pensamientos sobre el desarrollo de Linux

 Hoy quisiera compartirles algunos pensamientos sobre este fenómenal sistema operativo.

Linux ha logrado tener un lugar en el mundo informático, a veces lo vemos como algo normal dentro del mundo actual, pero su crecimiento no deja de ser fantástico.

Hoy en día grandes empresas están respaldando soluciones basadas en Linux. A nivel internacional y también a nivel regional la penetración de Linux es imparable.

Vivo en la ciudad de Torreón en México. Es una de las principales 20 ciudades del país, y veo con admiración y personal satisfacción la penetración que lleva Linux dentro de las grandes empresas regionales.

Se ha vuelto una herramienta que a las empresas comienzan a ver natural. Día a día es más difícil ver una empresa grande sin que tenga en su arsenal servidores Linux.

EN el plano internacional es todavía mayor el efecto. El compromiso de un gigante como IBM con el software libre era una fantasía hace unos años; y sin embargo, hoy es una realidad. Empresas que deciden empujar sus economías de la mano del software libre.

Estamos viviendo uno de los mejores momentos de la comunidad. Particularmente en el área empresarial.  

SIento que es un efecto natural debido a la comunidad. Gente con gran ingenio técnico y una preparación en sistemas son quienes soportan actualmente este fenómeno. La exigencia es que los sistemas sean robustos y funcionales, y estos valores son bienvenidos en las empresas. 

Conscientemente estoy dejando de lado el ambiente de escritorio, dejándolo intencionalmente para otro artículo.  

 Disfrutemos de este periodo, pues haciéndolo contribuimos a que siga adelante nuestro querido sistema operativo.

 

Interactive map of Linux kernel

The Linux Kernel is one of the most complex open source projects. There are a lot of books, however it is still a difficult subject to comprehend. The Interactive map of Linux Kernel gives you a top-down view of the Kernel.
You can see most important layers, functionalities, modules, functions and calls. You can zoom in and drag around to see details. Each item on the map is a hypertext link to source code or documentation.
 

Show progress when using "dd"

dd is a generic command-line tool for copying files from 1 location to another. It is often used to copy entire disk images.

Like many Linux command line tools, it operates silently unless something unexpected happens. Its lack of visual progress feedback is a nice feature for scripting. However, it can leave you wondering about its progress if you are interactively dd-copying a large disk.

To illustrate, you run the following (valid, but perhaps not very useful) dd copy:

$ dd if=/dev/random of=/dev/null bs=1K count=100

It will run for a few minutes as it copies (and immediately discards) 100 blocks of randomly generated data, each of size 1 KB.

To get a progress report while dd is running, you need to open another virtual terminal, and then send a special USR1 signal to the dd process.

First, find out the process id of the dd process by running the following in the new virtual terminal.

$ pgrep -l '^dd$'
8789 dd

To send the USR1 signal to the dd prcoess:

$ kill -USR1 8789

Note that as soon as the USR1 signal is detected, dd will print out the current statistics to its STDERR.

$ dd if=/dev/random of=/dev/null bs=1K count=100

0+14 records in
0+14 records out
204 bytes (204 B) copied, 24.92 seconds, 0.0 kB/s

After reporting the status, dd will resume copying. You can repeat the above kill command any time you want to see the interim statistics. Alternatively, you can use the watch command to execute kill at a set interval.

$ watch -n 10 kill -USR1 8789

----------------------------------
Or you can use "pv" command from "pv" package.
pv - is a terminal-based tool for monitoring the progress of data through a pipeline.

Try for example:

pv -ptre FILE | dd of=FILE bs=1M

Gives a nice output with a progressbar, good for writing cf cards from images.

---------------------------------
Or just use dcfldd - (DoD Computer Forensics Lab) dd replacement with hashing.
 

Why you should give the Vim editor a try

I've always been a Vim user, from the moment I had to make a change to a config file on my first Linux distribution (Corel Linux, be advised: stay clear!)

Vim is one of those programs that can amaze you after 10 years of daily use. It's mysteries and powers are only known to the one or two coders that know all of it's source code inside and out. 

Enough, blabber: time for some great gems of Vim ingenuity! 

Keyword completion

While in insert mode (i) press the CTRL+N or CTRL+P to start keyword completion. CTRL+N moves to the next item in the list, CTRL+P to the previous item. Very handy when you have to keep typing some obnoxiously long word such as nantuckednantucked, which yes, I made up.

Shorties

guu    Change entire line to lowercase

gUU   Change entire line to uppercase

xp      Switch the letter under the cursor with the next letter, easy fro fixign typo's

gf       Open the filename under the cursor

*        Search for the word under the cursor

Recording

Recording multiple commands is possible the best Vim feature there is. 

qa   Start recording a macro called 'a', you can use all letters from a - z

After you started recording, simply enter all Vim commands you want your macro to execute. Stop recording by pressing q again.

@a  Execute the commands you recorded in the macro called 'a'

 

 

 

Using sudo

Now that We have seen how to configure sudo, how do you use it? Sudo is very easy to use, as you will see. To determine what commands you have available to you via sudo, you can execute:

[ankit@black]$ sudo -l
Password:
User ankit may run the following commands on this host:
     (root) /etc/rc.d/init.d/httpd, /etc/rc.d/init.d/mysql
     (root) /bin/rpm, /bin/rm, /sbin/linuxconf
     (root) /usr/bin/swatch, /bin/touch
     (root) NOPASSWD: /bin/su
     (Jason) /home/Jason/bin/eggdrop, /home/Jason/bin/irc/ircd

This will show you exactly what commands you can run, and as what user. To use sudo to restart Apache, for example, you would use:

[ankit@black]$ sudo /etc/rc.d/init.d/httpd restart
Password:

After supplying his password, Apache will restart for Ankit. If he wanted to start eggdrop as Jason, however, he would have to approach it somewhat differently:

[ankit@black]$ sudo -u Jason /home/Jason/bin/eggdrop&
Password:

This will launch eggdrop in the background running as Jason's uid. Because sudo will, by default, try to run something as root, you must supply the user's username if it is a non-root user, as is the case here. Observe what happens if Ankit neglects to specify Jason's username:

[ankit@black]$ sudo /home/Jason/bin/eggdrop
Sorry, user ankit is not allowed to execute '/home/Jason/bin/eggdrop' as root
on black.somehost.com.

As you can see, sudo is very flexible, and very willing to replace su. In fact, I would even go so far as to make su only available through sudo. In order for su to work for non-root users (ie. allow non-root users to become root or any other user), /bin/su must have the setuid bit enabled, so it can run as root. If you remove the setuid bit from /bin/su, then even if a user knows the root password, they cannot su to root or any other user. Stripping setuid from /bin/su and restricting root logins from the console and via SSH is a very effective means of locking down unauthorized root access on your system. To do this, simply give yourself sudo access to run su (as illustrated with Ankit previously), and strip the setuid bit from /bin/su by executing (as root):

[root@black]# chmod u-s /bin/su
[root@black]# ls -l /bin/su
-rwxr-xr-x      1 root     root      18172 June 4 05:29 /bin/su*

Now if you try to run the command su - as a non-root user, even if you type in the right password for root, you will not change to root. In order for someone to use su, they must exist in sudoers with the appropriate permissions, and must run su through sudo like this:

[ankit@black]$ sudo su -
[root@black]#

I find this a much better approach to restricting access to root. By having su as a setuid application, any user on the system can attempt to execute su; if they have the root password or can guess it, they can become root. By having su access restricted through sudo, and with the setuid bit removed, the chances of breaking into root are much more limited. Think of it this way. If someone can compromise your box and obtain shell access as the user "apache" or "nobody", with su setuid, they can attempt to login as root, and if they find the password, there's no stopping them. With su being stripped of the setuid bit, even if someone obtains shell access as the user "apache", they are limited only to being able to do what the user "apache" has rights to. Even if they know your root password, they cannot su to root. They would need to guess Ankit's password in order to become Ankit, who could then become root via sudo. But even then, they could not use su to become Ankit, they would have to log into the system as Ankit.

To take the illustration further, this would mean they would need local console access to login as Ankit (if they had his password), or via SSH (since Ankit knows better than to run telnet). But Ankit's smart. He hasn't gone through the trouble of setting up sudo to let something like this stop him. He's also configured SSH to reject all password logins and only allow key-based authentication. Without Ankit's private key, no one is logging into his account via SSH. So even if your Apache server, or sendmail server, or DNS server, allowed someone to obtain shell access to your system with an unprivileged account, the damage they could do would be minimal. Without su being available to them as an unprivileged user, without having local console access, and without being able to log in to a user's account via SSH without having his private key, an attacker must resort to more difficult means of attacking your server to obtain root access. You can rest assured that you haven't made his job any easier by taking a few simple steps to protect yourself.

 
Page 117 of 132

Upcoming Linux Foundation Courses

  1. LFS230 Linux Network Management
    06 Oct » 09 Oct - Virtual
    Details
  2. LFD331 Developing Linux Device Drivers
    13 Oct » 17 Oct - Virtual
    Details
  3. LFS430 Linux Enterprise Automation
    13 Oct » 16 Oct - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board