Archive for the 'Linux Help' Category


Managing Linux Disk Space

In the process of installing programs, downloading/ripping movies, and doing whatever else we do with our Linux systems, managing disk space becomes crucial. Here’s some helpful hints on how to measure/manage disk space under Linux.

df

This command meaning ‘disk free’ will tell you how much of each partition you still have available to you. It handles all mounted filesystems including mounted samba shares. Due to it’s design as a tool to measure available disk space, it won’t tell you anything about your disk drives.

# dfthis outputs a display of the total partition usage
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda5 13100844 9906872 2528484 80% /
/dev/hda6 5463156 3245016 1940620 63% /mnt/v_drive
/dev/hda7 451564 68 451496 1% /tmp
/dev/hda8 6103648 3706120 2087476 64% /mnt/z_drive
/dev/hda9 24527248 16671184 7856064 68% /mnt/x_drive
/dev/hda1 8361512 5603640 2757872 68% /mnt/winxp
none 451564 0 451564 0% /dev/shm
//192.168.0.7/x 72595456 72282112 313344 100% /mnt/kingdom/x
//192.168.0.7/m 75335680 74567680 768000 99% /mnt/kingdom/m
//192.168.0.7/temp 75335680 74567680 768000 99% /mnt/kingdom/temp

# df -hthis outputs the same thing in a human-readable format
/dev/hda5 13G 9.5G 2.5G 80% /
/dev/hda6 5.3G 3.1G 1.9G 63% /mnt/v_drive
/dev/hda7 441M 68K 441M 1% /tmp
/dev/hda8 5.9G 3.6G 2.0G 64% /mnt/z_drive
/dev/hda9 24G 16G 7.5G 68% /mnt/x_drive
/dev/hda1 8.0G 5.4G 2.7G 68% /mnt/winxp

# df -kif you want to see things in Kilobytes
/dev/hda5 13100844 9906884 2528472 80% /
/dev/hda6 5463156 3247992 1937644 63% /mnt/v_drive
/dev/hda7 451564 68 451496 1% /tmp
/dev/hda8 6103648 3706120 2087476 64% /mnt/z_drive
/dev/hda9 24527248 16671184 7856064 68% /mnt/x_drive
/dev/hda1 8361512 5603640 2757872 68% /mnt/winxp

du

‘disk usage’ measures individual sections of the filesystem rather than whole partitions. You can pass it a directory name or nothing at all to let it calculate the current directory.

# duthis lists, recursively, the size of all directories beneath the current directory.
68 ./.kde3.4/share/config/session
8 ./.kde3.4/share/config/kresources/contact
4 ./.kde3.4/share/config/kresources/calendar
4 ./.kde3.4/share/config/kresources/konnector
4 ./.kde3.4/share/config/kresources/notes
24 ./.kde3.4/share/config/kresources
12 ./.kde3.4/share/config/colors
648 ./.kde3.4/share/config
32 ./.kde3.4/share/apps/kconf_update
4 ./.kde3.4/share/apps/kopete
4 ./.kde3.4/share/apps/remoteview
8 ./.kde3.4/share/apps/nsplugins
... etc ...

# du /home/danger -hthe same thing as the above but for a certain directory and with better units for filesizes (KB, MB, GB).
68K /home/danger/.kde3.4/share/config/session
8.0K /home/danger/.kde3.4/share/config/kresources/contact
4.0K /home/danger/.kde3.4/share/config/kresources/calendar
4.0K /home/danger/.kde3.4/share/config/kresources/konnector
4.0K /home/danger/.kde3.4/share/config/kresources/notes
24K /home/danger/.kde3.4/share/config/kresources
12K /home/danger/.kde3.4/share/config/colors
648K /home/danger/.kde3.4/share/config
32K /home/danger/.kde3.4/share/apps/kconf_update
4.0K /home/danger/.kde3.4/share/apps/kopete
..... etc ......

# du -shcalculates the size of the current directory’s total contents (and prints it in ‘h’ format).
204M

Tricky 1337 stuff

As I learn more about terminals and bash commands I’m finding some excellent shortcuts for common operations. They’re nothing secret, they’re just new to me.

# df -h | grep /dev/hda5 show just one partition/device in the list. You can replace the ‘/dev/hda5′ with any other text that you’re looking for.
/dev/hda5 13G 9.5G 2.5G 80% /

# df -h | grep /dev/hda5 | cut -c 41-43 same as above, but it further narrows down the output to include only the 41st through the 43rd characters of the list - which is the part that shows percentages.
80%

# du –exclude=logthis will ‘du’ all the files except ones that match the pattern in the exclude clause. In this case, any file that contains the three-letter combo ‘log’ will not be counted in the results. Can be really handy also for ignoring movies, music, etc.



If any of you have something to add, please chime in - I’d be happy to add your comments as an update to this post (as well as try out the new comment display I’ve got - they show up opposite the post on the right side of the page).

Setting up Samba Server

I was trying to let a Windows computer access some multimedia files on my Gentoo laptop recently. I forgot that I hadn’t set up samba server on my most recent installation so I decided to do it and write about it at the same time. This is not a full explanation of how to configure samba, it’s just a way to help you do it as quick as possible.

Getting Samba
For Gentoo users like myself the process of installing samba is just typing:
# emerge samba
For Debian/Ubuntu users:
# apt-get install samba samba-common
For other folks you can either use your given package management tool (Suse: Yast, Mandriva: Rpmdrake, etc.) or just install the rpm directly. You can find an rpm appropriate for your system here.

Configuring Samba
There are some programs built to configure samba for you, but it’s really quite easy to edit the configuration file by hand. With root privileges open the file /etc/samba/smb.conf

My system gave me a default file that looked like this:

[global]
server string = faith
wins support = no
workgroup = SpiritNet

“faith” is my computer name and “SpiritNet” is the name of my workgroup. This much was configured automatically by some Gentoo tool. If you’re file is blank or doesn’t exist don’t worry. You should at least have a file named /etc/samba/smb.conf.example or something like it to look at as an example. Just copy what I’ve got above and change the values to match what you want.

To share a directory you’ll need the following things:

  • know the path to the folder you want to share
  • know what you want to call the samba share
  • know whether you want any anonymous user to be able to save/delete on the share

I’ll share how my smb.conf file looks after I’ve set up one share. It’s a partition mounted as /mnt/z_drive and I want it to be world-writeable.

[global]
server string = faith
wins support = no
workgroup = SpiritNet

[x_drive]
path = /mnt/x_drive
read only = no
printable = yes
guest ok = yes

After I save this file I only have to restart samba. This command may be different on your system from mine. Basically all it is is calling the samba program with a space and then the word ‘restart’. I’ll share two possible locations for samba (these are both potentially restart commands):
# /etc/rc.d/init.d/smb restart
# /etc/init.d/samba restart

This should give you a fully working samba server that people can connect to. This is only a brief overview of getting samba working and configured, but you can get a full instruction manual below:

All about samba (this page can also be optained by typing # man samba).

Mounting a Samba Share

I just had to do this so I figured I’d pass along the hint.

If you have a windows computer on the same network as your Linux computer, you can access the windows files as if they were built into your Linux computer’s file system. For the quick and easy way, use this code:

mount -t smbfs -o username=myname,password=12345 //windows/filefolder /mnt/windowsfiles

The above code works every time you type it, but to make it mount at boot you’ll need to edit your fstab file.

Edit /etc/fstab with vi,vim,nano,kwrite or whatever you use to edit files (just make sure you have root privileges while editing it). Add this line:

//windows/filefolder         /mnt/windowsfiles         smbfs     credentials=/home/myname/.smbcredentials,rw     0 0

Then create that credentials file by type this:

echo username=myname > /home/myname/.smbcredentials
echo password=mypassword >> /home/myname/.smbcredentials

Then to mount all file systems listed in /etc/fstab:

mount -a

You should never have to think about that again. Hopefully.

Xauthority - cannot open display:

Gtk-WARNING **: cannot open display:
cannot open display 0:0

Most of the time it’s a very bad idea to operate your Linux computer as root. There are those times, however, when you need to launch an application with root privileges. Every time I install a new version of Linux I run into this problem and here’s the solution:

If you can’t open X programs as root, you need to type the following:
# su
# [type the password]
# echo 'xauth -f /home/[your user account here]/.Xauthority list 0:0'

where you replace the stuff in brackets with the appropriate values.

If you found this post helpful, please leave a comment.
(feel free to ask about other Linux problems you’re having - I read all comments)

Install Linux Multiple Times

There is an excellent tutorial for installing multiple Linux distros on a single hard drive over at Shell Shocked.org. I ran into some problems with my installation of Gentoo (an upcoming article for the Distro Installs category) and this page really helped me out.

I was mostly looking for details on editing the bootloader configuration file (I use LILO, so I needed help with /etc/lilo.conf), but this page is golden for anyone who’s power-happy.

Holly Bostick is an excellent writer and an OS guru. In her article she gives clear instructions on how to install many different versions of Linux and multiple versions of Windows all on the same hard drive - all while conserving space.

Tutorial: Multiple Linux Distros by Holly Bostick

Free beginner’s course on Linux

Starting March 17 2005 and going until April 22 there will be a free online course for learning Linux. It’s offered jointly by the Dee-Ann LeBlanc and the HP Learning Center

It’s a free class guided by a real instructor. If you miss the starting date you’re welcome to join in late (it is the web after all). Here’s the course description:

This course is a survey for anyone who is unfamiliar with the Linux operating system. You’ll gain an understanding of the concepts and issues around Linux, find out what versions are available and how to get them, and learn how to accomplish basic installation, desktop use, and administration tasks.

Enroll at this address

Linux Viruses and Linux Spyware

Windows users have to be constantly on guard against viruses and spyware. Using Firefox significantly lowers the number of programs that illicitly install themselves, but the problem remains and is increasingly costly.

Linux users don’t need to fear spyware in the way Windows users need to for several reasons:

  • Not nearly as many people use Linux as Windows, so a virus has a better chance if it’s written for Windows
  • There is more diversity in the way Linux is structured than Windows - so it is difficult to predict what kind of system a Linux virus would run into
  • There are many ‘features’ of Windows that allow simple scripts to do powerful things without any security protection.
  • Virus writers know that the average Linux user is far more computer savvy than the average Windows user, so they go for easier targets
  • Linux has a built-in permissions system that keeps programs that one user runs from infecting all the other programs (see first link at end of article).

There have been some semi-successful worms and viruses on Linux, but they’ve existed primarily as a mathmatical curiosity than as a threat to commerce. Occasionally there are worms that affect certain web applications that run on Linux (like the recent worm that affected PHPBB2 bulletin boards), but this is a result of poor PHP or Perl practices rather than a fault in Linux.

So should *nix users be wary of spyware? No, not really. That is, until Linux is the most common operating system. It’s already the core of OSX and there are rumors that Windows is planning on a Linux sandbox to run inside of Windows. Then we’ll need to pay more attention.

For more information on Linux viruses:
Linux: The short life and hard times of a Linux virus
Linux GUIs could allow viruses

The Might of File Networking

For those who have a Windows box and a Linux box on the same network (especially if it’s a home network), it’s absolutely essential that you give yourself the convenience of mounting your Windows drive in Linux.

It’s possible to make a folder on your Linux machine (I use /mnt/[computername]/[sharename] but you can use whatever folder you want) work like a folder on your Windows machine. When you navigate to it you read your Windows files, and you can save files to your Windows machine by saving them to this folder.

For a complete instruction on how to do this, check out Mounting Samba Shares Permanently. All you need is to have file sharing enabled on your Windows computer and share the folder (it could be a whole drive) that you want to access.

note: to share a folder right-click on it and click “sharing”, then give it a name.

Dual Booting Linux and Windows

A common way to start using Linux is to have a working Windows XP installation taking up a full drive and wanting to give just a little room to Linux. This is how I started long ago and it’s not too unlike how I do it now.

There are some hitches to installing Linux and Windows together, some of which involve the MBR (Master Boot Record). Those who have attempted to dual-boot systems will surely have one or two stories of unexpectedly-overwritten MBRs.

Here is an article about using NTLDR (the Windows software for the MBR) and keeping Windows intact, while installing Linux into a second hard drive.

The computer in question was a standard white-box PC with Windows XP installed on its one hard drive. One option was to shrink the exiting Windows partition with NTFSresize and install Linux in the resulting free space. However, this was too intrusive. I did not have a backup of the data on the Windows machine, and didn’t want to take the time to make one, so I was loath to do anything that could wipe it out.

Note: The instructions given in this article could just as easily be applied to installing Linux into a partition on the primary drive. The only change required would be to install GRUB or LILO into hda2 (or whatever number) instead of hdb.

System Backup

Keith Winston on NewsForge
writes:

In eight years of running Linux, I had never needed to completely restore a production system. Most restores were for individual files or directories. In moments like this, it is evident how important a well-tested backup system is.

This is a complete lesson on running complete system backups and restores using nothing more than tar and some scripts to run it.

For those who are stuck using expensive, commercial software to do server backups, try out Keith’s method. It’ll likely save money on software while providing a universally-understood method of backing up and restoring data (since having tar is as common as having a keyboard).

Installing Linux for the first time

For the first-timers out there who’re looking to set up their first Linux server, there’s a great tutorial at LinuxPlanet
that walks through the whole procedure of obtaining Linux, preparing the box, and installing the software.
It’s not a technical article, in fact it lacks even basic depth, but it’s contains most of the information you’ll need.

Linux is now a lot simpler than you may think. We can provide you with the easiest, simplest, no-problem process for installing Linux on a PC. After going through this simple installation process, you will have a basic machine that you can configure into any kind of server, workstation, or office desktop. Future articles in this My First Linux Server series will help you build productive, Linux-based servers and small office workstations.

It’s true that Linux is getting easier. Take advantage of it and try an installation yourself.

Running Linux on Windows - VMWare

In Eric Clapsaddle’s Article A Linux Island in a C:\ of Windows, Part 1 | Linux Journal he discusses how to use Linux at work without buying any new hardware or trying to dual-boot anything. VMWare is a handy program that simulates a computer within your computer, so you can have a whole different PC running in a window on your desktop. The best part of this article is one of the comments: (by Paul Archer)

Repartition your drive and install Linux as if you were going to do a standard dual-boot setup. Then run VMWare under Windows and point it to the Linux partition. Now when you’re ready to switch to Linux as the primary OS, you can boot to Linux and setup VMWare on Linux to run Windows.
With this setup, you have the ability to access both OSes from either OS. And SuSE has a system profile switcher that would come in really handy for running Linux under VMWare and then switching to running natively.

My First Linux Server: Setting Up Gentoo

If you’re thinking of setting up a webserver that runs linux (and why would you run anything else (besides BSD)) here’s a guy who’s making a server that runs Gentoo. If you’re in the process of deciding which linux distribution is best to run a server or if you’re interested in running Fluxbox on a server, here ya go: My First Linux Server: Setting Up Gentoo

Serial ATA (SATA) on Linux

The Linux Mafia has put out a report on running serial ATA (SATA) on Linux. If you’re running serial ata (SATA) on Linux or trying to run SATA on Linux, then you should check this page out.

Good excerpt from the page:

There is no such thing as a distribution or its installer (generically) “having SATA support” (or not). Please send anyone speaking in such terms to this page. (Some SATA chipsets have been supported since practically forever, as their programming interfaces are unchanged from PATA predecessors. Others are brand-new and require new drivers from scratch.)

Linux Hardware Problem and Solution Page

Here’s a web page that is absolutely no help to me. Still, I recommend checking it out just to see how a detailed help page looks. This guy has what he calls the Linux Hardware Problem and Solution Page which does precisely one thing: It lists the voltage and some other setting requirements of a specific motherboard so you’ll know how to compile your linux kernel to work with that motherboard. This guy’s brilliant, but this page is useless to all but four people.

I give this example as a way to illustrate how difficult it is to collect really useful data into a Linux help page. You can either be too broad and help no one, or too specific and help just one or two people. I think this is why forums like the one at LinuxQuestions.org are important because it collects the sum of all the knowledge of it’s visitors, whether newbs or pros and selects just parts of that knowlege to answer specific questions. In my opinion this is a much better way to run a help site. Not to knock the guy at the first link - he wasn’t going for a comprehensive page.

Popular Posts:


    Fatal error: Call to undefined function rjb_mostwanted() in /home/studioda/distrojockey.com/wp-content/themes/tertiary/archive.php on line 87