Thread: *****LINUX TIPS WAREHOUSE*****
-
October 21st, 2003, 06:38 PM #41Member
- Join Date
- Jun 2003
- Posts
- 222
Introduction to running apps remotely with *NIX
--------------------------------------------------------------------------------
Since the very beginning, UNIX and related OS's were designed to be used by remote terminals, rather than a keyboard and display device connected directly to the system. Although nowadays most people control their *NIX systems with a keyboard, monitor, and possibly a mouse connected directly to the system, you can still do almost anything remotely that you can do locally.
Throughout this guide, the term 'Local System' will mean the computer you are sitting at, and 'Remote System' will mean the server that the applications are being run on.
If you want to run applications over your network, there are a few different programs that you will most likely use. Here's a description of them:
ssh: secure shell. Using an SSH server on the remote system, and an SSH client on the local system, you can log into and get a command prompt from the remote system. You can do anything at this prompt that you could at a command prompt on the remote system's screen.
The X Window System: This is a suite of programs that provide a graphics infrastrucure for *NIX. It consists of an X server, which creates a framebuffer for graphical apps, and X clients, software that uses the X server to display a graphical interface. When the X server is run on the local system and the X clients are run on the remote system, you've got remote X.
Running command-line apps remotely is trivial, to say the least. Just log in to your remote system with SSH and do it. If your local system runs *NIX, you almost cerainly have the OpenSSH client. To use it:
ssh username@name.or.ip.of.server
You'll be asked for your password. Enter it, and you will be logged in. If you're running Windows, and don't have Cygwin, you'll need an SSH client. I recommend PuTTY. Just download, unzip, and then run PuTTY.exe. The default options are fine, but if you know what you're doing, feel free to tweak it to whatever extent you want to. Just enter your remote system's name or IP, select SSH, and click Connect. Enter your username and password when asked, and you're in.
Running GUI apps is less trivial, as you need to set up remote X. There are a few ways to do this, such as setting up an SSH tunnel, and some simpler methods. What I will describe is a very simple method, which is not secure, and won't work through a router. The X client on the remote system will connect directly to the X server on the local system, with no tunneling.
You need an X server running on the local system. If you're using *NIX, I'll assume you have and are running X, since you almost certainly are. If you're using Windows, you will need to obtain and set up an X server. I recommend the one included in Cygwin. Anyway, here's how to do it:
1. Open up a local command prompt.
2. xhost + ip.of.remote.system
3. SSH into the remote system.
4. export DISPLAY="ip.of.local.system"
5. Run your graphical app. If all is well, you will see the app on the local screen.
There is also another method for remote GUIs, that is probably a lot easier to set up and use: VNC. Now, I'm sure that you've all heard of VNC in the past, and maybe even used it on Windows, but it's a bit different on *NIX. Instead of sharing the remote system's screen, it creates virtual screens of arbitrary size and color depth. I strongly recommend you use TightVNC, as it has quite a few more features and uses less bandwidth. Here's how to set it up:
1. Download and unpack the source code.
2. Follow the instructions in README to install it. Make sure you compile and install Xvnc, since there are some extra steps you need to do to get it.
3. Once it is installed, run the VNC server. To get a virtual 1024x768 desktop, run:
vncserver -geometry 1024x768 -depth 24
It will tell you what the display number of the VNC server is. You will need this number to use it. If you're not running X when you start VNC, it will probably be :0, if you are, it will probably be :1. the first time you run it, it will ask for a password. Enter one you can remember.
You can now use any VNC client, either for Windows or *NIX, to connect to it. Just start the client, then connect to ip.of.server:display#. You will be asked for your password, enter the one you gave when you started the VNC server. If all goes well, you will now get a window with the virtual desktop on it. Open an xterm, and run this:
export DISPLAY="127.0.0.1:display# of vnc server"
Then run whatever graphical apps you want to use, and they will pop up on the VNC display.
I hope this has been informative.
-
October 21st, 2003, 06:38 PM #42Member
- Join Date
- Jun 2003
- Posts
- 222
Mounting ISO files, encrypting hard drives, and other applications of the Linux Loopback Device
**************************************************
One of the most useful features of Linux is the Loopback device. This is a function of the Linux kernel that lets you do things like mount ISO files without burning it to a CD,
create an encrypted filesystem, hide a filesystem with steganography, create initialization RAM disks for boot CDs and floppies, and much, much more. This FAQ will tell you
how to use it.
There are two ways to create a loopback device. The simplest is using mount with the -o loop switch, and more complex things can be done with losetup.
The former just lets you mount a filesystem that resides within a normal file, such as an ISO, whereas the latter lets you do things like encryption.
In this FAQ, I will tell you how to do three things using the loopback device:
1. Mount an ISO file without burning it to a CD
2. Create a simple filesystem within a file
3. Create a simple encrypted hard drive partition
First, however, you need to have loopback support in the kernel. The kernels included in almost every distro out there either have support built in, or available as a module. If
you get errors when trying the commands below, try running modprobe loop as root. If that produces an error, you will most likely need to compile a new kernel. Whilst
going through the configuration options, ensure that you enable "Loopback Device Support" in the Block Devices section.
Another thing you might want to recompile your kernel for is to apply the crypto patch. In addition to other things, this allows you to use far stronger encryption methods on
the loopback device. If I understand correctly, the best you can do without it is XOR encryption, which is easier to crack than an egg. I will elaborate on this at the end of the
FAQ.
Now, with that out of the way, on to the application examples.
Mounting an ISO without buring it to a CD
This is, by far, the thing I miss most when I am forced to use windows. With a single command, you can mount an ISO file directly off of the hard drive, as if it were a CD.
The command to do this is:
mount -o loop -t iso9660 filename /mnt/cdrom
Explanation:
mount: Involks the mount command.
-o loop: Specifies that the option "loop" be passed to mount. This tells it to attach the specified file to a loopback device, and the mount that automaticly.
-t iso9660: Specifies that the ISO-9660 filesystem is being used. mount can detect this by itself, but I always specify it anyway.
filename: This tells mount what file to mount.
/mnt/cdrom: The mount point that will be used. This can be any directory. /mnt/cdrom and /cdrom are considered the standard places to mount CDs, so that's what I
use.
When you are done with it, unmount it using this command:
umount -d /mnt/cdrom
Explanation:
umount: Involks the umount command.
-d: Tells umount to free the loopback device. You can omit this, but the loopback device that was used will remain bound to the file.
/mnt/cdrom: The mount point you used.
Note that this is not limited to ISO files, you can use this procedure for any filesystem embedded in a file, just substitute iso9660 with the correct filesystem. More information
on that in the next example.
Creating a filesystem within a file
There are many reasons why you may want to create a filesystem within a file. Maybe you want seperate filesystems for /home, /usr, /var, and so on without messing
around with setting up partitions. Maybe you want to create a RAM disk for a boot floppy or CD. Maybe you want to test a filesystem utility you're writing. That does not
matter. Regardless of why you're doing it, it is a pretty easy thing to do. Here's the procedure:
1. Create a blank file of the needed size using dd:
dd if=/dev/zero of=filename bs=1M count=size
Explanation:
dd: Runs the dd command.
if=/dev/zero: Tells dd that the data source is /dev/zero, which is a "device" that just spits out zeroes.
of=filename: Tells dd to create a file called filename.
bs=1M: Tells dd to create the file in 1 MB blocks. This can be anything, but using a value like this makes it easier to figure out what to specify for count=.
count=size: Tells dd to copy size blocks, whose size is specified in the bs= parameter.
Example for a 800 megabyte file called loopfile: dd if=/dev/zero of=loopfile bs=1M count=800
2. Create a filesystem in the file. The command varies widely based on what filesystem you use, but most are of the format mkfs_tool_name filename. Here's an
example for Ext3:
mke2fs -j filename
Explanation:
mke2fs: Runs mke2fs, the program that creates ext2 and ext3 filesystems.
-j: Stands for journal. Tells mke2fs to make an ext3 filesystem.
filename: The name of the file you made with dd in step 1.
3. Mount the filesystem. The command for this is exactly the same as the one used to mount an ISO file as explained above, except you replace iso9660 with the type
of filesystem you created in step 2. The same is true for unmounting.
Encrypting a hard drive partition
This is where you can see just how useful the loopback device can be. Using a fairly simple series of commands, you can create an encrypted volume to store your
pr0^H^H^Hfinancial records and other sensitive material. Note that it does not have to be a hard drive partition, you can make a blank file with dd and use that if you want
to, but it seems to me that a seperate hard drive partition is better for this. Anyway, here's how to do it:
1. Make a blank partition if you haven't done so already.
2. Use losetup to bind the partition to a loopback device with encryption. Depending on what kind of crypto you want to use, and any other options you might want to use,
this command varies, but here's an example:
losetup -e xor /dev/loop0 /dev/sda1
Explanation:
losetup: Runs losetup, the program that controls loopback devices.
-e xor: Tells it to use XOR encryption.
/dev/loop0: Tells it what loopback device to use. There are 8 you can use, ranging from loop0 to loop7.
/dev/sda1: Tells it that the data is to be stored on the first partition of the first SCSI hard drive. Replace this with the device or file the data will reside upon.
When you run this, you will be asked for a password.
3. From now on, just use /dev/loop0 where you would normally use /dev/sda1 (or whatever you used), as it works just like a normal hard drive partition.
4. When you are done with it, run losetup -d /dev/loop0 to detatch it. When you need to access it again, just repeat step 2.
Note, however, that XOR encryption isn't very tough. As I said at the beginning of this FAQ, to get stronger encryption methods, such as twofish and aes, you need the
crypto patch for the kernel, and you also need a patched version of losetup from the util-linux package. Here's how to set that up:
1. Download the crypto patch. It is called "patch-int-kernelversion.patchversion.bz2" and can be found at any kernel.org mirror, in the /pub/linux/kernel/people/hvr/testing directory. At the time of writing, the latest one is patch-int-2.4.19.2.bz2.
2. Switch to your kernel source directory. This source must be clean to apply the patch, so run make mrproper. Note that this will delete your .config, so put it somewhere safe, like /usr/src or your home directory.
3. Apply the patch. This command assumes that you downloaded the bzip2 compressed patch, and it is in the directory above the source directory. bzcat ../patch-int-2.4.19-2.bz2 | patch -p1
4. Copy your .config back into the kernel source directory, and then run your favorite kernel configurator.
5. Enable CryptoAPI support, all the message digest algorithims, any ciphers you want (No harm in enabling all of them), and Loop crypto support (under crypto devices).
6. Before you run make dep, you need to apply the cryptoloop patch. It can be found in the same place as the crypto patch, and is named "cryptoloop-version.tar.bz2". Latest as of time of writing is cryptoloop-0.0.1-pre1.tar.bz2. Download and extract it, then enter its directory.
7. Patch the kernel. make patch-kernel KDIR=/kernel/source/directory LOOP=jari
8. Switch back to the kernel directory, and then compile and install it as normal.
You now have a kernel with CryptoAPI. However, as the README indicates, you need a patched losetup utility to take full advantage of it. Here's how to get that:
1. Download the util-linux source code if you don't already have it. It can be found at any kernel.org mirror, in the /pub/linux/utils/util-linux directory. The filename is "util-linux-version.tar.bz2". Latest at time of writing is util-linux-2.11w.tar.bz2. Save it somewhere and unpack it.
2. Download the patch. It too can be found at any kernel.org mirror, in the /pub/linux/kernel/people/hvr/util-linux-patch-int directory. Filename is "util-linux-version.patch.bz2". Get the one whose version is closest to the util-linux package you downloaded.
3. Switch to the util-linux source code directory, and apply the patch. Assuming the patch is in the directory above the util-linux source, the command is: bzcat ../util-linux-2.11r.patch.bz2 | patch -p1
4. Compile it. ./configure && make
5. Install losetup and its man page. cp mount/losetup /sbin/losetup && chown root.root /sbin/losetup && cp mount/losetup.8 /usr/man/man8/losetup.8
-
October 21st, 2003, 06:39 PM #43Member
- Join Date
- Jun 2003
- Posts
- 222
COOL ONES
***********
Getting help:
man command - Almost always shows you the manual for the specified program. When told to 'RTFM', this is what you must do.
man -k word - Kind of like a search engine for man.
Moving around the file system:
Navigating the Unix file system is very similar to DOS. Some of the commands are a little different, but they generally behave the same.
cd dirname - Changes to the specified directory.
cd .. - Changes to the parent of the current directory.
pwd - Prints the current directory. Usefull if, for whatever reason, your prompt doesn't give this info.
ls - Directory listing. use the -lh switch to get a detailed listing. Use the -a switch to show hidden files.
Archives:
tar xzf file.tar.gz - Unpack a .tar.gz file. Doesn't work in all systems. I believe this is a feature of GNU tar and the tar on Solaris will not have this functionality. Use gtar if you want this feature. BSD's tar should have this functionality also.
tar xf file.tar - Unpack an uncompressed .tar file.
gunzip file.gz - Uncompress any .gz file, tar or otherwise. If the file you are decompressing is a .tar.gz, it will not be unpacked, it will simply become a normal .tar file.
uncompress file.Z - Uncompress any standard .Z (compressed using the compress command) file.
bunzip2 file.bz2 - Uncompress any .bz2 file.
tar cf file.tar dirname - Put the contents of a directory into a .tar file.
gzip file - GZip compress a file.
bzip2 file - BZip2 compress a file. This is a pretty good compression method, it would be the suggested method if it was more standard on various Unix and Unix-like systems.
Viewing and editing files:
cat - Outputs the contents of a text file to stdout. Only useful on small files or simple manipulation.
more - A somewhat simple text file reader. The SPACE bar moves you one page forward, the ENTER key moves you one line forward, and many times the "b" key will move you one page backwards.
vi file - A really nice text editor, albeit a bit tricky to use.
Environment variables:
PATH - Tells the shell where to look for programs if you don't tell it exactly where it is. It works like the DOS PATH variable, but with colons ( instead of semicolons ( to seperate the entries. For example: /bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:/opt/mozilla
ie. (for Bourne based shells)
PATH="$PATH:/usr/local/bin"
export PATH
DISPLAY - Tells the machine where to display graphical applications
ie. (for Bourne based shells)
DISPLAY="name_of_machine:0.0"
export DISPLAY
export - In Bourne based shells (ksh appears to be default on Solaris), this command is used to set an environment variable.
setenv - csh based shells use the setenv command to set environment variables. ie.
setenv PATH "$PATH:/usr/local/bin"
-
October 21st, 2003, 06:39 PM #44Member
- Join Date
- Jun 2003
- Posts
- 222
How do I access my computer running Linux from my Windows desktop?
***********************************************
There are multiple ways to do this.
If you are content with just accessing the Linux console, you can use ssh or telnet.
Alternately, you can use HyperTerminal? or something similar to access your Linux console over a serial port. Doing this is beyond the scope of this answer; however, this document covers this information. (Most of the HOWTO covers how to use an actual hardware terminal, which is what the likes of HyperTerminal? emulate. The section I have linked to covers setting up your Linux computer.)
If you want to access files on your Linux computer, you can set up Samba to have it show up as a network resource under network neighborhood. For now, see http://samba.linuxbe.org/ for a nice, friendly tutorial on setting up Samba.
If you wish to have access to the Linux GUI, there are two major ways to do this.
You could obtain and run a piece of software known as an "X11 server" on Windows. Popular commercial X11 servers include Hummingbird eXceed, StarNet X-Win32 and MicroImages MI/X.
Free-of-cost open-sourced X11 servers for Windows include WeirdX (written in Java) and Cygnus XFree86 (somewhat hard to set up).
Install the X11 server on your Windows desktop.
Now, it depends if you have Linux boot into a GUI (i.e., whether or not your have a graphical login screen instead of a console login).
If you have a graphical login, you can use the XDMCP feature of the X11 server on your Windows desktop to connect to your Linux server's xdm service (which provides graphical login). Connect to yourlinuxmachine:0.
If you log in on console, set up SSH on your Linux machine and install an SSH client on your Windows machine. Set up the SSH client to enable X11 forwarding (this should be one of the available configuration options).
Most modern distributions have SSH already set up for X11 forwarding. However, the official OpenSSH? distribution does not. In order to enable X11 forwarding on the server, log in as root. Locate the file sshd_config using the command
locate sshd_config
(typically /etc/sshd_config or /etc/ssh/sshd_config)
and use a text editor (like vi, nedit, gedit or kedit) to edit it. See if there's a line such as
#X11Forwarding yes
(note the # sign). If so, remove the # before X11Forwarding. (If there's no # sign, you don't have to do anything. If there's a `no' instead of a `yes', change it to a `yes'.)
Save the file and exit your editor. Restart your computer or the ssh daemon to have the changes go into effect.
Now you can run the X11 server on your Windows desktop and use SSH to connect to your Linux machine. Start any GUI program in your SSH console, and its windows should pop up on your Windows desktop.
The other option is to use VNC. VNC is a fantastic little remote access system, available for most UNIX operating systems, as well as for Windows and the Mac OS.
Obtain the VNC server binary package for Linux and install it. Run vncpasswd and set a remote access password (and remember it!). Start the VNC server:
vncserver :10 -geometry 800x600 -depth 24
Obtain and install the VNC viewer for Windows on your Windows desktop. Run it, and connect to yourlinuxmachine:10.
The neat thing about VNC is that it also comes with a Java applet client and acts as a web server. You can start up a Java-capable web browser and access
http://yourlinuxmachine:5810
and the Java applet should load and start up. Note, however, that the performance of the Java applet client is nowhere near as good as that of the native Windows client.
If you just want the advantages of having UNIX command-line utilities on your Windows desktop, you don't need to run Linux at all for this. .
-
October 21st, 2003, 06:41 PM #45Member
- Join Date
- Jun 2003
- Posts
- 222
Faxing from Windows to a Linux fax server
Mini-HOWTO: Sending faxes with Windows eFax, Linux and Samba.
Part 2: a Faxmail facility for your users.
A little mini HOWTO made by "pappavis".
OVERVIEW:
Right, so you have a linux box, you want to send faxes with your fax mode. And, you don't wannt to shell out for a commercial
fax program like WinFax or whatever. To the rescue comes eFax for your faxing needs.
The installation and configuration not for dummies, you gotta have some Linux experience to accomplish tasks. Things like RPMs and printcap should be familiar, if not then your about to learn it. Stay with me, this is a great FREE solution for even big sites.
INSTALLATION of the Fax
* Install eFax take the RPM's.
* set the /etc/printcap to use my faxlpr script which must be chowned to executable.
* Create a printer in Samba, naming it in Samba the same as the fax printer that was setup by eFax RPM /etc/printcap.
* Restart samba for the printer to be activated.
* Add a new postscript network printer to windows, use the Apple Laserwriter, set the networkprinter to \\yourserver\fax.
* Look at my printer script, u need perl as well. Set some things inside, its logical..
* Print something from windows
Please note: Your document need to have the words Fax:<space>number becos the linux machine uses a pattern matching thing!!!
Thats all for now, u can mail me if u have questions.
-
October 21st, 2003, 06:41 PM #46Member
- Join Date
- Jun 2003
- Posts
- 222
How do I configure my Sound Card
****************************
With Red Hat Linux, you can run the utility
sndconfig
from the command line (not in x-windows) as root, and it will walk you through easily setting up a PCI or ISA sound card. This is the easiest way I've seen to set up your sound card. If this does not detect it, run
pnpdump
which will give you info about your pnp devices and allow you to set them up.
-
October 21st, 2003, 06:41 PM #47Member
- Join Date
- Jun 2003
- Posts
- 222
How do I define a crontab entry?
***************************
Thought I would post this for future clarification, especially as there is an exception to the normal "AND" function when day of month and day of week are both specified.
All credit to the author Paul Vixie...
A crontab file contains instructions to the cron daemon of the general form: ``run this command at this time on this date''. Each user has their own crontab, and commands in any given crontab will be executed as the user who owns the crontab. Uucp and News will usually have their own crontabs, eliminating the need for explicitly running su(1) as part of a cron command.
Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. Note that comments are not allowed on the same line as cron commands, since they will be taken to be part of the command. Similarly, comments are not allowed on the same line as environment variable settings.
An active line in a crontab will be either an environment setting or a cron command. An environment setting is of the form,
name = value
where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in value will be part of the value assigned to name. The value string may be placed in quotes (single or double, but matching) to preserve leading or trailing blanks.
Several environment variables are set up automatically by the cron daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd line of the crontab's owner. HOME and SHELL may be overridden by settings in the crontab; LOGNAME may not.
(Another note: the LOGNAME variable is sometimes called USER on BSD systems... on these systems, USER will be set also.)
In addition to LOGNAME, HOME, and SHELL, cron will look at MAILTO if it has any reason to send mail as a result of running commands in ``this'' crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the owner of the crontab. This option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as your mailer when you install cron -- /bin/mail doesn't do aliasing, and UUCP usually doesn't read its mail.
The format of a cron command is very much the V7 standard, with a number of upward-compatible extensions. Each line has five time and date fields, followed by a user name if this is the system crontab file, followed by a command. Commands are executed by cron(8) when the minute, hour, and month of year fields match the current time, and when at least one of the two day fields (day of month, or day of week) match the current time (see ``Note'' below). cron(8) examines cron entries once every minute. The time and date fields are:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 0-31
month 0-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
A field may be an asterisk (*), which always stands for ``first-last''.
Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11.
Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''.
Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies skips of the number's value through the range. For example, ``0-23/2'' can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to say ``every two hours'', just use ``*/2''.
Names can also be used for the ``month'' and ``day of week'' fields. Use the first three letters of the particular day or month (case doesn't matter). Ranges or lists of names are not allowed.
The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
Note: The day of a command's execution can be specified by two fields day of month, and day of week. If both fields are restricted (ie, aren't *), the command will be run when either field matches the current time. For example,
``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
EXAMPLE CRON FILE
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to `paul', no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"
EXTENSIONS
When specifying day of week, both day 0 and day 7 will be considered Sunday. BSD and ATT seem to disagree about this.
Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would be rejected by ATT or BSD cron -- they want to see "1-3" or "7,8,9" ONLY.
Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9".
Names of months or days of the week can be specified by name.
Environment variables can be set in the crontab. In BSD or ATT, the environment handed to child processes is basically the one from /etc/rc.
Command output is mailed to the crontab owner (BSD can't do this), can be mailed to a person other than the crontab owner (SysV can't do this), or the feature can be turned off and no mail will be sent at all (SysV can't do this either).
-
October 21st, 2003, 06:42 PM #48Member
- Join Date
- Jun 2003
- Posts
- 222
Backup from Linux to Windows using SMBmount
*****************************************
Here is the modified file for taking backup from linux to windows using smbmount.
1. Replace NTUsername with network id and NTPassword with network password.
2. Make the folder shared where you want to take the backup. You should give the full access to that network login ID.
3. The owner of this script should be root.
4. Be sure that, smbd and nmbd are running. If not, start them.
5. If normal user wants to run this script, then be sure that the setUID bit is set for /usr/bin/smbmnt.
6. Add proper values for DIRTOARCHIVE, MNTPOINT, and ARCHIVETO.
7. Modify the smbmount command parameters as per your requirement.
################################################## ####################
#!/bin/sh
#
# Script to backup the /home volume
ADMINID="NTUsername"
ADMINPASSWD="NTPassword"
DAY=`date +%Y%m%d-%H%M`
BACKFILE=<ProjectName>.source.$DAY.tgz
LOGFILE=/tmp/$DAY.backup.log
STARTTIME=`date`
DIRTOARCHIVE=<Directory path to archieve >
MNTPOINT=<Some directory having all permission >/forBackup$DAY
ARCHIVETO=$MNTPOINT/Source/Archive
# First umount and then mount.
###############################
umount $MNTPOINT
mkdir $MNTPOINT
smbmount <//Windows NT server/Folder for backup> $MNTPOINT -o username "$ADMINID/<workgroup>%$ADMINPASSWD"
# Generate the backup file
###############################
cd $ARCHIVETO
if [ `pwd` != "$ARCHIVETO" ]
then
echo "Aborting backup"
umount $MNTPOINT
rmdir $MNTPOINT
exit 2
fi
{
echo "\n\n"
date
echo "Archiving $DIRTOARCHIVE\n"
echo "The backup file is $BACKFILE\n"
echo "Logfile is $LOGFILE
"
tar -cvzf $BACKFILE $DIRTOARCHIVE
echo "End of tar process...."
} >| $LOGFILE
# Unmount
###############################
cd /
umount $MNTPOINT
rmdir $MNTPOINT
-
October 21st, 2003, 06:42 PM #49Member
- Join Date
- Jun 2003
- Posts
- 222
How do I recover a lost/forgotten Root password
****************************************
Here are the instructions into breaking into your own system if you've lost your root-password. This is taken from an article I found in Linux Gazette, written by Mark Nielsen (http://www.linuxgazette.com/issue41/nielsen1.html).
This document assumes you are partitioned thusly:
/dev/hda1 swap
/dev/hda2 /
/dev/hda3 Dos
Author refers to Redhat 5.2 but this will work with subsequent versions (I've tested it).
Steps:
1. Make system bootable from CD-rom (either in BIOS or use a boot floppy that will do so).
2. Put Linux Distribution CD into cd-rom drive and turn on computer.
3. Pretend to go through installation of distribution and after it asks you to put in the CD-rom and it gets to the next screen you can now go to the second console window.
4. Press Alt-F2, Alt-F3, Alt-F4, Alt-F5 and then Alt-F1. You should see the various screens with different messages. The one we want is Alt-F2.
5. Press Alt-F2.
6. Type "cd /tmp" and press enter. This takes us to a directory where we can make files, directories, etc...
7. Now we will make a temporary directory and a temporary device for the partition on the hard drive that we want to look at or edit. Type the following:
mkdir /tmp/my_dir
mknod /tmp/my_dev b 3 2 #the two is taken from hda"2"
above, so should be wherever your "root" partition is.
mount /tmp/my_dev /tmp/my_dir
df
8. "mkdir" makes a directory for us to mount the a partition to. "mknod" makes a device for 2nd partition on the master hard drive (hda2). This lets us "see the partition. In particular, "b 3 2" means "b" is for block device, "3" is the master hard drive on the primary IDE controller and "2" means the second partition.
"mount" takes the device we can "see" and puts it on top of the directory /tmp/my_dir.
"df" lets you see what filesystems are mounted and where.
Now we can iether edit the password file or perhaps something like turning off xwindows from starting up if you have a computer using xdm. Let's do the password
9. type: "cd /tmp/my_dir/etc" then "vi passwd"
10. You need to know how to use vi (a great editor found on almost every UNIX by default). "x" deletes a character, "i" inserts characters, "Esc" turns on and off command mode/insert mode, "wq!" writes, quits and ignores any problems with
read-only files, "h" moves one character to the left, "l" one character right, "k" up one line, "j" down one line.
11. Now in the passwd file press "j" until you get to the line you want to be on "root" (for our example)
root:x:0:0:root:/root:/bin/bash # here we want to delete the "x" which is telling
us the password is shadowed.
Now type "wq!" (without the quotes)
12. Now type "vi shadow"
You may see a line for root that looks like this
root:$1$Upkf7iIA$.nSNmn0MkoRP2srJsUx.0/:11321:0:999999:7:::
just delete everything between the colons to make it look like
root:::::::: # that's 8 (eight) colons after the word "root"
Now type "[Esc], :, wq!, enter" to write the file, quit and ignore read-only problems.
13. Now you're done editing the file, what is the problem now? If you reboot you will likely lose all of your changes. You must unmount the directory, THEN reboot.
14. Do this > "cd /tmp" > "umount /tmp/my_dir" > "df"
15. After ensuring you unmounted ok, press CTRL-Alt-Del to reboot. Also, take the cdrom out fo the cdrom drive. When your computer restarts I'd recommend having your BIOS boot off the hard drive rather than the CD-rom.
That's it, this is very useful in the case of lost/forgotten root passwords. But it's also good for fixing other problems when you just can't get it booting the right way. As I said, I plagarised the hell out of his article. But it was a great article and helped me out immensly. I hope Mr. Nielsen doesn't mind my copying his work for this forum.
-
October 21st, 2003, 07:00 PM #50
wow!!!
well I'll be trying linux for the first time later tonight
I think I'm not ready for this thread yet
-
October 21st, 2003, 08:55 PM #51Member
- Join Date
- Jun 2003
- Posts
- 222
Hey Dudes.. Do Share Ur Linux Tips..
-
October 25th, 2003, 02:01 PM #52Member
- Join Date
- Jun 2003
- Posts
- 222
How to Play (with) Favorites
And speaking of Favorites, serious web surfers often like to relocate that folder to some other location, so that their own favorites won't get tossed into the bit bucket if something bad happens to Windows itself. Some Registry hackers make the logical assumption that the way to do this is to open the following Registry key and look for the line shown here:
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Explorer\Shell Folders
NAME
Favorites Data
"C:\Windows\Favorites"
Just change the “C:\Windows\Favorites” to say, “D:\Favorites” or some other convenient location. There's only one problem with this solution: it doesn't work. When you exit the Registry Editor, Windows looks to see where the Favorites folder really is and then re-writes the entry accordingly. So here's one situation where low-tech is the way to go. Forget about the damned Registry and just drag the Favorites folder off to wherever you want to park it. Windows will watch you and now that the folder really is in a new location, it will re-write the Registry entry to point to it.
-
October 25th, 2003, 02:33 PM #53
I cant wait to try that out on my Linux box
Seldom right,but never in doubt...
-
October 25th, 2003, 05:34 PM #54
Hey netgeek I think you forgot/miss Pasted that tip
. Darn ctrl+V
.
-
October 25th, 2003, 06:33 PM #55
I gotta say, some of this is humorous, step 4 of kernel compiling, "Choose all options" Quite the kernel you have there
I would say this had to have come from the super piggy pig pig of google knowledge. If only there was a filter for incomplete information eh
-
October 25th, 2003, 07:50 PM #56
As far as recovering a lost password, simply boot into sinlge user mode and issue the passwd command.
Much eaiser than that 20 step process above
JkrohnSignatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)



LinkBack URL
About LinkBacks







Watch Fast And Furious 6 Online... Watch The Hangover 3 Online Watch Fast And Furious 6 Online Watch The Internship Online Watch Iron Man 3 Online Watch Man Of Steel Online Watch Now You See Me...
Watch Fast And Furious 6 Online...