Unix noob adventures

Where Penguins and Daemons chill together in the warmth of the Sun.

Moderators: SecretSquirrel, notfred

Unix noob adventures

Postposted on Sun Dec 07, 2008 11:11 am

Unix noob here. Tried it a few times before and said screw it. Now I am in a better position to make a long term effort - I have multiple machines, I have a router, I have high speed internet, and I have an interest in how FreeBSD or Linux could be useful in a network environment.

So, first off: OMG, thank you for PuTTY. I knew that SSH meant secure shell, and that secure shell was somehow a way to logon remotely, and so one or two googles led to PuTTY, and it is *gasp* simple and extremely useful. Gawd it is convenient. Now I don't have to sit in my cold-ass basement to play with FreeBSD. Just grab the laptop, sit on the couch, and fire up PuTTY. Bliss. PuTTY has made exploring the Unix universe much much much less of a chore. No extra keyboard, mouse, and monitor needed after the OS gets installed, just a network connection!

So, does PuTTY support multiple terminals in the same session, or do I have to fire up multiple sessions of PuTTY to use multiple terminals?

Is there a way to shut down the computer through the PuTTY terminal? Usually I just hit the power button on the machine. I don't actually know the Unix command to shut down the computer.

Also, is is proper to refer to generic things as Unix, or is Posix a more accurate term? For example, should I say Unix command or Posix command? Or should I always be system specific and say FreeBSD command or Linux command?
Last edited by flip-mode on Wed Feb 04, 2009 11:43 am, edited 3 times in total.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: Unix noob discovers PuTTY

Postposted on Sun Dec 07, 2008 11:28 am

flip-mode wrote:So, does PuTTY support multiple terminals in the same session, or do I have to fire up multiple sessions of PuTTY to use multiple terminals?
I don't know about PuTTY, but you might want to look into GNU screen. It's a very useful terminal multiplexer with a surprisingly flexible feature set. You'd just fire up screen from within a PuTTY session and then you can create multiple virtual terminals within the screen session. You can also detach from a running screen session, terminate your PuTTY connection and then later re-connect and re-attach to your running screen session with all of your stuff the way you left it (editors still running, etc.).

flip-mode wrote:Is there a way to shut down the computer through the PuTTY terminal? Usually I just hit the power button on the machine. I don't actually know the Unix command to shut down the computer.
Running "shutdown -h now" is one way (you need to run with root privileges, so run using sudo or su or logged in as root).

flip-mode wrote:Also, is is proper to refer to generic things as Unix, or is Posix a more accurate term? For example, should I say Unix command or Posix command? Or should I always be system specific and say FreeBSD command or Linux command?
POSIX is a set of standards, one of which refers to the shell/command environment, but a lot of times people are operating out of that safe portable subset. In Linux, many of the common POSIX-required tools are the GNU implementations and have extra (and typically quite useful)features that you may be using, and a lot of the system administrative commands are distro or Linux-specific. I guess it's a matter of taste, but I'd be specific unless you have a reason otherwise and know you're using a POSIX-approved subset of commands.
bitvector
Grand Gerbil Poohbah
 
Posts: 3234
Joined: Wed Jun 22, 2005 4:39 pm
Location: Mountain View, CA

Re: Unix noob discovers PuTTY

Postposted on Sun Dec 07, 2008 11:41 am

bitvector wrote:
flip-mode wrote:So, does PuTTY support multiple terminals in the same session, or do I have to fire up multiple sessions of PuTTY to use multiple terminals?
I don't know about PuTTY, but you might want to look into GNU screen. It's a very useful terminal multiplexer with a surprisingly flexible feature set. You'd just fire up screen from within a PuTTY session and then you can create multiple virtual terminals within the screen session. You can also detach from a running screen session, terminate your PuTTY connection and then later re-connect and re-attach to your running screen session with all of your stuff the way you left it (editors still running, etc.).
It sounds like that is something I have to install on the FreeBSD machine? I haven't gotten as far as installing anything yet - maybe that should be one of my next pursuits.

bitvector wrote:Running "shutdown -h now" is one way (you need to run with root privileges, so run using sudo or su or logged in as root).
Sweet, thanks.

flip-mode wrote:I guess it's a matter of taste, but I'd be specific.
Good enough.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: Unix noob discovers PuTTY

Postposted on Sun Dec 07, 2008 11:51 am

flip-mode wrote:It sounds like that is something I have to install on the FreeBSD machine? I haven't gotten as far as installing anything yet - maybe that should be one of my next pursuits.

Yeah, it's in ports under sysutils.
bitvector
Grand Gerbil Poohbah
 
Posts: 3234
Joined: Wed Jun 22, 2005 4:39 pm
Location: Mountain View, CA

Re: Unix noob discovers PuTTY

Postposted on Sun Dec 07, 2008 11:54 am

Cool BV, thanks.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: Unix noob discovers PuTTY

Postposted on Sun Dec 07, 2008 12:04 pm

bitvector wrote:Running "shutdown -h now" is one way (you need to run with root privileges, so run using sudo or su or logged in as root).

Actually, for some reason I glossed over the fact you specified you're running FreeBSD in your original post. You should use "shutdown -p now" to power off the system in FreeBSD. shutdown -h means "halt" and in Linux it also powers off the system, whereas in FreeBSD, -h just halts the system but leaves it powered on sitting there doing nothing, so they have a -p option to halt and power off. Heh, a good illustration of why to be system specific with your commands. :lol:
bitvector
Grand Gerbil Poohbah
 
Posts: 3234
Joined: Wed Jun 22, 2005 4:39 pm
Location: Mountain View, CA

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 10:49 am

If you want, you should even be able to get a full remote desktop going. There are two ways to approach this -

- Install Cygwin/X on the Windows side, and enable remote X logins on the BSD box. (Cygwin also includes its own SSH client, but PuTTY may still be a slightly better choice for Windows since it is a native Windows app instead of a port of a Linux one.)

- Install a VNC viewer on the Windows side, and install a VNC server on the BSD box.
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 37664
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 11:09 am

just brew it! wrote:If you want, you should even be able to get a full remote desktop going.
I'd be all about that, but I have yet to figure out how to get X working on the local machine. X seems to be completely unconfigured.

I'm not to worried about getting X working in the short term. The main goal of all of this is to get familiar with the system and then implement a BSD firewall at work. Any advice / guidance towards that end is hugely appreciated. And I'm taking a long term view on this too. If it takes months to get it sorted out, so be it.

Edit, FWIW, I discovered PFsense and haven't gotten a chance to test it out yet, but it seems the obvious choice, at first glace, for implementing a firewall.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 1:07 pm

PuTTY + screen and you're good to go.
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4199
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 2:07 pm

flip-mode wrote:The main goal of all of this is to get familiar with the system and then implement a BSD firewall at work. Any advice / guidance towards that end is hugely appreciated.

If I were implementing a firewall for something important, I'd do (at least) two boxes with pfsync and CARP. You don't want a dead firewall to kill your connectivity. With that stack (if it was just a firewall), I'd probably use OpenBSD though.
bitvector
Grand Gerbil Poohbah
 
Posts: 3234
Joined: Wed Jun 22, 2005 4:39 pm
Location: Mountain View, CA

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 2:26 pm

Hmm, I was considering just imaging the hard drive and if it ever goes down just swap in the other hard drive. I also have an identical spare machine on stand by. If my skills become advanced enough I will surely consider the "pfsync / CARP" solution.

I am setting out on this mission with essentially zero Unix experience.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 5:09 pm

axeman wrote:Cygwin always seemed like a lot of work to me... The Xming X server for Windows is pretty easy to setup: http://sourceforge.net/projects/xming

Well... I like Cygwin more for the full set of command line tools than the X server. But FWIW they've finally started maintaining the X server (Cygwin/X) again, after several years in limbo.
(this space intentionally left blank)
just brew it!
Administrator
Gold subscriber
 
 
Posts: 37664
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Unix noob discovers PuTTY

Postposted on Mon Dec 08, 2008 8:55 pm

bitvector wrote:If I were implementing a firewall for something important, I'd do (at least) two boxes with pfsync and CARP. You don't want a dead firewall to kill your connectivity.

Hadn't come across that, it looks pretty neat: http://www.countersiege.com/doc/pfsync-carp/
notfred
Grand Gerbil Poohbah
 
Posts: 3730
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: flip's Unix noob adventures

Postposted on Tue Dec 09, 2008 12:00 pm

alright, I've tried to su, read the man page for su, but can't get it to work

I want to run make build to get screen compiled so I can install it. I've tried the following:

su - make build
su -c root make build
su root make build

all of which are obviously wrong. someone throw me a rope, please.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Tue Dec 09, 2008 1:08 pm

flip-mode wrote:all of which are obviously wrong. someone throw me a rope, please.

"su root -c make build" is one way. I'd just do su - and then use the root shell to run make and whatever else I needed (actually, I'd install sudo from ports and use that, but I guess you need to do this first anyway).

Also, unlike on Linux, the user running su has to be a member of the group "wheel" on FreeBSD. Also remember, unlike sudo is typically configured, with su you type the password of the user you are changing to, not the user running the command.
bitvector
Grand Gerbil Poohbah
 
Posts: 3234
Joined: Wed Jun 22, 2005 4:39 pm
Location: Mountain View, CA

Re: flip's Unix noob adventures

Postposted on Tue Dec 09, 2008 8:22 pm

Well, bummer, it seems I've forgotten my root password. I suppose I'll reinstall tomorrow. Darn, what the heck was that password....

Other than that, I think my user account was not a part of the wheel group, cause every time I tried to su I'd always get "sorry".
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Tue Dec 09, 2008 9:47 pm

If you can boot a rescue disk of some sort (sorry, I don't know what to recommend on the BSD side of things) then you can go in and remove the root password that is currently configured - you may need to mount the current hard drive and then edit /etc/passwd. Reboot and you now have root with no password and can just run "passwd" as root to set up a new one.

You may want to write important passwords down on a piece of paper and then seal it in an envelope that you keep safe. If you forget them, you can open the envelope. The point of sealing them in an envelope is at any point you can check that it is still sealed and then you know nobody else has read the paper. If you ever find the seal disturbed then you can suspect that the passwords have been compromised and take appropriate action - probably just change the password, but maybe if you are extra paranoid you can reinstall to make sure no rootkits have been installed.
notfred
Grand Gerbil Poohbah
 
Posts: 3730
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: flip's Unix noob adventures

Postposted on Tue Dec 09, 2008 10:10 pm

Wheee! FreeBSD fun!

Just a pure FWIW remark, not meaning to steer you, but I found it easier to play with FreeBSD once I'd already cut my teeth on nix-isms in Linux. Linux gives you a little easier/smoother/less work type path in, and FreeBSD is the real power tool once you're in and up.

You're in feet-first, and if you manage and get by, you'll scoff at the tards who get started with the easy kiddy linux stuffs. Good luck, I'll keep tabs.

(BTW, I'd strongly recommend too many putty sessions over learning screen, I never even bothered getting to the latter.)
Siglessness is boring.
Image - M4800-Eight1
Image - Vargr-Z97
Forge
Lord High Gerbil
 
Posts: 8010
Joined: Wed Dec 26, 2001 7:00 pm
Location: SouthEast PA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 9:52 am

So it turns out that I hadn't forgotten the password. Apparently, PuTTY, at least by default, does not allow one to logon as root, or else FreeBSD does not allow remote logon as root by default.

So, with that problem solved, I can go about adding myself to the wheel group I guess.

Here are just a list of questions / tasks I have on my mind:

configure root logon through putty
adding a second network card - how to install and configure
how to add new users
can I change my user name?
configuring FreeBSD as a firewall
how to create a network share that can be seen by windows machines?
doing something with su just to make sure I know how to use su, once I'm a wheel member of course

Also, regarding pfsync and CARP, is the main idea redundancy? I was considering using pfSense and having an identical backup computer and doing something like a once a week image, although pfsync and CARP does seem to be a more sophisticated solution. But pfSense looks super easy to use. There is something to be said for ease of use, so does anyone have any experience with pfSense?
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 10:07 am

axeman wrote:I believe you would need to edit /etc/ssh/sshd_config to allow root logon through SSH. However, you should be able to ssh as a regular user, then use su to elevate privileges.
lollers, I suspect you are right. But first I have to get myself some permission to use su. Apparently, in Linux, anyone can su, and this is due to Richard Stallman's love for the masses (I just found out). But in BSD and other *nixes that don't use the GNU su, users must be a member of the wheel group. Right now I'm in the process of figuring out how to make myself a member, but if someone feels like posting instructions here, I certainly won't mind! :lol:
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 10:11 am

oh god, that was easy, flip-mode is now a member of the wheel group :lol: thank you google!

and I just tested su in PuTTY and I can do it now, so no need to logon as root in PuTTY

Edit: By the way, I love the easy editor! Has anyone else used it? It's just so friggin simple. In time I am sure I'll have to learn Vi or Emacs or whatev, but for now I'm loving using ee!
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 10:17 am

flip-mode wrote:Edit: By the way, I love the easy editor! Has anyone else used it? It's just so friggin simple. In time I am sure I'll have to learn Vi or Emacs or whatev, but for now I'm loving using ee!


I'm a NANO person. It reminds me of edit in the good ol DOS days. Never bothered learning vi or emacs. An emac is an Apple product, and vi is just 6. Nano at least means small, and 'minimal' as a cognate isn't a horrible stretch.
Siglessness is boring.
Image - M4800-Eight1
Image - Vargr-Z97
Forge
Lord High Gerbil
 
Posts: 8010
Joined: Wed Dec 26, 2001 7:00 pm
Location: SouthEast PA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 10:20 am

For security reasons, I would suggest not editing your sshd configuration to allow direct root logins. Two reasons: attackers will definitely try that username, and picking the correct username is half of what they need to get in, and root, if it's compromised, has god privileges over the system.
Think for yourself, schmuck!
i5-2500K@4.3|Asus P8P67-LE|8GB DDR3-1600|Powercolor R7850 2G|1.5TB 7200.11|1988 Model M|Saitek X-45 & P880|Logitech MX 518|Dell 2209WA|Sennheiser PC151|Asus Xonar DX
bthylafh
Grand Gerbil Poohbah
 
Posts: 3157
Joined: Mon Dec 29, 2003 11:55 pm
Location: Southwest Missouri, USA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 10:23 am

Forge wrote:I'm a NANO person. It reminds me of edit in the good ol DOS days. Never bothered learning vi or emacs. An emac is an Apple product, and vi is just 6. Nano at least means small, and 'minimal' as a cognate isn't a horrible stretch.


I usually use nano as well, but it's worth learning at least basic vi and emacs commands. Some commands (like vipw) default to using vi.

ed is the standard Unix text editor. :wink:
Think for yourself, schmuck!
i5-2500K@4.3|Asus P8P67-LE|8GB DDR3-1600|Powercolor R7850 2G|1.5TB 7200.11|1988 Model M|Saitek X-45 & P880|Logitech MX 518|Dell 2209WA|Sennheiser PC151|Asus Xonar DX
bthylafh
Grand Gerbil Poohbah
 
Posts: 3157
Joined: Mon Dec 29, 2003 11:55 pm
Location: Southwest Missouri, USA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 10:31 am

bthylafh wrote:For security reasons, I would suggest not editing your sshd configuration to allow direct root logins. Two reasons: attackers will definitely try that username, and picking the correct username is half of what they need to get in, and root, if it's compromised, has god privileges over the system.
I agree. I don't even like logging on as root myself, because, to begin with, every nix guide advises against it.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 12:41 pm

Not allowing remote root login is a security feature. Allowing remote root login allows other to attempt to log into your box as root. Whereas when that's disabled, they have to guess and get into a legitimate account that's in wheel before they can even begin to attempt hacking root.

What's so hard about just logging in as yourself, then doing an su? Or a much better practice, logging in as yourself and just using sudo.
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4199
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 12:43 pm

flip-mode wrote:
axeman wrote:I believe you would need to edit /etc/ssh/sshd_config to allow root logon through SSH. However, you should be able to ssh as a regular user, then use su to elevate privileges.
lollers, I suspect you are right. But first I have to get myself some permission to use su. Apparently, in Linux, anyone can su, and this is due to Richard Stallman's love for the masses (I just found out). But in BSD and other *nixes that don't use the GNU su, users must be a member of the wheel group. Right now I'm in the process of figuring out how to make myself a member, but if someone feels like posting instructions here, I certainly won't mind! :lol:


Yes, Linux is pretty infamous for not following Best Practices in the Unix community for security (and other things). That's the problem with the masses -- they have no experience about why certain things are done (or that they're done at all).

Not having "." in your path and not allowing remote root login are two of the important ones that come immediately to mind.
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4199
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 1:08 pm

Buub wrote:What's so hard about just logging in as yourself, then doing an su?
Well, now that I've made myself a member of the wheel group, there is nothing hard about it at all :wink:

As for sudo, I'm going to have to check it out; as of this moment, I don't know what sudo is.
flip-mode
Gerbil Khan
Silver subscriber
 
 
Posts: 9084
Joined: Thu May 08, 2003 12:42 pm
Location: Cincinnati, OH

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 1:10 pm

Buub wrote:Not having "." in your path and not allowing remote root login are two of the important ones that come immediately to mind.

Which distros put "." in your PATH by default? Obviously I can't speak for all distros, but I can't think of one I use regularly that does that.
bitvector
Grand Gerbil Poohbah
 
Posts: 3234
Joined: Wed Jun 22, 2005 4:39 pm
Location: Mountain View, CA

Re: flip's Unix noob adventures

Postposted on Wed Dec 10, 2008 1:21 pm

bitvector wrote:
Buub wrote:Not having "." in your path and not allowing remote root login are two of the important ones that come immediately to mind.

Which distros put "." in your PATH by default? Obviously I can't speak for all distros, but I can't think of one I use regularly that does that.

Not anymore. But "back in the day" it was as common as new users logging in and doing everything as root, just because it was easier.
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4199
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA

Next

Return to Linux, Unix, and Assorted Madness

Who is online

Users browsing this forum: Glorious and 2 guests