The Official *nix Thread

Inane baanter or words of wisdom - you decide...
Post Reply
User avatar
piku
Sheepie Whore
Sheepie Whore
Posts: 20960
Joined: Wed Apr 24, 2002 10:44 am 0
Website: Http://Www.ncot.uk
Location: Wakefield
Contact:

Post by piku »

RageMatrix wrote:
mount -t cifs //<host IP>/<sharename> /mnt/sharedir
Seems a bit daft that it can't resolve Windows machine names, tho. Or not.
Netbios names are crap. They rarely work properly in Windows-land. They also lead to the bonkers situation of a computer having two names on the network - its "windows" name ("My Laptop") and its FQDN ("officepc.home.lan" or whatever).

When I used to install Linux servers I could waste hours tracking down bizarre errors caused by Windows PCs not resolving names properly.

Watch out if you put your password in config files on on the commandline, especially if you recycle the same password all the time.
return (0);
User avatar
WiteWulf
Sheepie Whore
Sheepie Whore
Posts: 10125
Joined: Mon Aug 23, 2004 11:20 am 0
PSN: WiteWulf
Location: Loughborough(ish)

Post by WiteWulf »

You get exactly the same problem when you multi-stack DECnet or Appletalk with TCP/IP, it's nothing new...
:::G:::

PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
User avatar
piku
Sheepie Whore
Sheepie Whore
Posts: 20960
Joined: Wed Apr 24, 2002 10:44 am 0
Website: Http://Www.ncot.uk
Location: Wakefield
Contact:

Post by piku »

WiteWulf wrote:You get exactly the same problem when you multi-stack DECnet or Appletalk with TCP/IP, it's nothing new...
Never owned a Mac, so had forgotten about AppleTalk. Is it still used or have they gone for something that talks to Windows machines instead?

I do remember once configuring a network that had Macs, Linux and Windows machines on it. The Linux box ran the AppleTalk and Samba services so the Mac and Windows machines could share files. It was quite painful to make work reliably.
return (0);
User avatar
WiteWulf
Sheepie Whore
Sheepie Whore
Posts: 10125
Joined: Mon Aug 23, 2004 11:20 am 0
PSN: WiteWulf
Location: Loughborough(ish)

Post by WiteWulf »

OS X still supports Appletalk and AFP but the standard these days is for TCP/IP and samba (with all it's inherent bugs and shortcomings).
:::G:::

PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
User avatar
dom
Baaaaa!
Baaaaa!
Posts: 1370
Joined: Wed Feb 09, 2005 1:17 pm 0
Location: Edinburgh, UK and level 691859
Contact:

Post by dom »

oops, posted twice
Last edited by dom on Tue Jan 08, 2008 9:13 pm 0, edited 3 times in total.
OMG (or oligodendrocyte myelin glycoprotein) is a molecule found in your central nervous system.
User avatar
dom
Baaaaa!
Baaaaa!
Posts: 1370
Joined: Wed Feb 09, 2005 1:17 pm 0
Location: Edinburgh, UK and level 691859
Contact:

Post by dom »

If you have the relevant version of the samba client, there's "nmblookup" which should allow you to add "wins" as an option for hostname lookups in the file /etc/nsswitch.conf (which determines how various information is gathered) if the windows machine is in the same subnet, e.g.

Code: Select all

hosts:          files wins dns
You can lookup names from the commandline of your *nix box:

Code: Select all

$  nmblookup lap-win2k
querying lap-win2k on 192.168.0.255
192.168.0.251 lap-win2k<00>
There are options for nmblookup if you have a WINS server on another subnet which you want to query, so long as it is aware of them.

It should be possible to list the shares on a windows or samba server with 'smbclient':

Code: Select all

$ smbclient -L \\lap-win2k
password:
Domain=[FORBURY] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]

        Sharename       Type      Comment
        ---------       ----      -------
        IPC$            IPC       Remote IPC
        games           Disk      
        ADMIN$          Disk      Remote Admin
        C$              Disk      Default share
etc.
Not all *nixes have an smbmount command, but mount.cifs seems to be there where smbmount isn't on two linux boxen I have. You might only have smbclient, which is a bit more of a pain to use.

Code: Select all

ubuntu-pc $ sudo smbmount \\\\192.168.0.251\\c$ /mnt/c/ -o username=administrator

suse-pc $ sudo mount -t cifs \\\\192.168.0.251\\games /mnt/c -o user=dominic
in a bash script I use this under IRIX or Linux to get the contents of \\servername\attachments\$1, although it messes up if the directory doesn't exist:

Code: Select all

smbclient \\\\servername\\attachments -W myworkgrp -c  'cd '$1'; prom ;dir ; mget *'
Samba has its own database of passwords (see man smbpasswd) and its shares, printers etc. are defined in smb.conf (usually in /etc/samba), but I find it a lot easier to export a directory from a linux server via NFS and Samba than to get smbclient or smbmount to work from a linux box, mainly due to the syntaxes above.

ok, I'll shush now. corrections welcome.
OMG (or oligodendrocyte myelin glycoprotein) is a molecule found in your central nervous system.
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Post by RageMatrix »

Thanks dom, interesting stuff.
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
Dungeon-Dave
Baaaaaa!
Baaaaaa!
Posts: 3925
Joined: Thu Aug 04, 2005 12:01 pm 0
Location: UK
Contact:

Post by Dungeon-Dave »

RageMatrix wrote:Gah..
In fact, when su'ing to root from my regular normal account in a terminal window in GNOME, I don't seem to have a path at all, so I have to type stuff like /sbin/ifconfig rather than just ifconfig. Do I need to change something in my /etc/profile?
No, you need to use "su - root" not "su root" (or even "su -").

With the "-", you pick up root's profile (and thus their path). Without, you still look in user areas (misses out /usr/local/sbin, /sbin, for instance).

It's a fairly common mistake. Try "echo $PATH" as a mortal user than as root, using both variations on the SU command. You'll see the difference.

nb: look at using sudo rather than su to do rooty things.
User avatar
Dungeon-Dave
Baaaaaa!
Baaaaaa!
Posts: 3925
Joined: Thu Aug 04, 2005 12:01 pm 0
Location: UK
Contact:

Post by Dungeon-Dave »

RageMatrix wrote:Seems a bit daft that it can't resolve Windows machine names, tho. Or not.
It can, but it's not particularly good at it since it uses some proprietry NetBIOS shite known only to Microshaft which changes each time Andrew Tridgell and his merry hoarde manage to understand (during their breaks in reverse-engineering BitLocker traffic and various other unamerican things) - to the point that not even BillyShit networking copes with it.

I think Redmondware eventually realised that NetBIOS, NetBUEI, WINS and other winshit-specific toss caused an additional headache on top of standard Inet protocols (DNS and the like) that they revised their ideas with W2K upwards. From that point it's safer to have some internal DNS+DHCP system on the LAN that maintains host records to aid resolution.

I know for small networks, broadcast traffic and network master domain browser elections are simple "plug it in and it eventually works" but they really confuse things during network troubleshooting and become a right major pain as your network begins to grow.

(the amount of times I could happily put my fist through a MCSE's face when their idea of network connectivity was double-clicking Network Neighbourhood and equating icons with connectible machines.. grrr...)
User avatar
JQW
Baaaaa!
Baaaaa!
Posts: 1186
Joined: Thu Feb 22, 2007 12:23 pm 0
Location: Ripon, where nothing ever happens.

Post by JQW »

If you want real fun, try to add a Samba server to an Active Directory domain. Yes it can be done, but only with heaps of voodoo with Kerberos and the like. Not for the faint hearted that one.
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Post by RageMatrix »

Dungeon-Dave wrote:
RageMatrix wrote:Gah..
In fact, when su'ing to root from my regular normal account in a terminal window in GNOME, I don't seem to have a path at all, so I have to type stuff like /sbin/ifconfig rather than just ifconfig. Do I need to change something in my /etc/profile?
No, you need to use "su - root" not "su root" (or even "su -").

With the "-", you pick up root's profile (and thus their path). Without, you still look in user areas (misses out /usr/local/sbin, /sbin, for instance).

It's a fairly common mistake. Try "echo $PATH" as a mortal user than as root, using both variations on the SU command. You'll see the difference.

nb: look at using sudo rather than su to do rooty things.
Thanks. I got snarled at at LinuxQuestions.org for this - like I should've known that... :roll: :D

Still not sure I see the different between su and sudo, but I'll look into it today.
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
Dungeon-Dave
Baaaaaa!
Baaaaaa!
Posts: 3925
Joined: Thu Aug 04, 2005 12:01 pm 0
Location: UK
Contact:

Post by Dungeon-Dave »

RageMatrix wrote:Still not sure I see the different between su and sudo, but I'll look into it today.
Coupla advantages:
- you don't need root password to sudo commands, but you do for su.
- you can permit someone to run specific commands as root without them knowing root pass (but only specific accounts, and specific commands) so it's much tighter than full root privs.

On most of my servers, I've either forgotten root pass (I never use the account anymore) or locked it out.

footnote: yes, I *am* fucked if I descend into "init 1" territory... but I know how to get into OSen without root pass in DR situations, so it ceases to become important to me.
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Post by RageMatrix »

Ah. First thing I thought was "how can you decide who has root access to what files, then?" But then I found this, which seems to cover it.

http://www.courtesan.com/sudo/intro.html
http://www.courtesan.com/sudo/man/sudoers.html
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
Dungeon-Dave
Baaaaaa!
Baaaaaa!
Posts: 3925
Joined: Thu Aug 04, 2005 12:01 pm 0
Location: UK
Contact:

Post by Dungeon-Dave »

Just a point in note: the "su" command means "switch user", not "super user" - ie: it is used to change to another user account. Most people use it to switch from their user account to become root, so it's commonly mistakenly thought of as the "super-user" command, not the "switch-user" command (yes, you probably know this already!)

In the same vein, the "sudo" actually means "switch-user do" rather than "super-user do". Whilst most people use it to allow mortals to run some commands as root, it is also used to allow ordinary users to run certain commands as another user (non-root).

One example is that some users can be given permissions to shutdown/startup a database - they will need to become the "dba" user rather than "root" to do it. Using sudo they won't need the dba password.
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Post by tufty »

Dungeon-Dave wrote:One example is that some users can be given permissions to shutdown/startup a database - they will need to become the "dba" user rather than "root" to do it. Using sudo they won't need the dba password.
Heresy! Burn the heretic!

The correct way to start a database is to fill in 15 forms requesting the DBA to stoop as low as to carry out this menial task. Once these have been filed and rejected, you take the DBA down the pub and ply him with strong alcohol until he's agreed to show you how the backups work. Once he's passed out at the console, you can start your database.

Kids today. Feh.
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
Post Reply