Search Amazon.com:
Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us $3,400 per month for bandwidth bills alone, and since we don't believe in shoving popup ads to our registered users, we try to make the money back through forum registrations.
  • Post
  • Reply
KaeseEs
Feb 23, 2007

by Fragmaster


Alfajor posted:

I'm trying to figure out some C code (basically a if (chmod (file,mode)) ). What is the return type of chmod, and more importantly, what's what? 1 true? or 0 is true?

The manual is your friend here. Sections 2 and 3 cover system calls and standard library functions, respectively. Thus:

man 2 chmod posted:

CHMOD(2) Linux Programmer’s Manual CHMOD(2)

NAME
chmod, fchmod - change permissions of a file

SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>

int chmod(const char *path, mode_t mode);
int fchmod(int fildes, mode_t mode);

...

RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.

...

Adbot
ADBOT LOVES YOU

KaeseEs
Feb 23, 2007

by Fragmaster


JoeNotCharles posted:

If you don't have the manpages installed on your system, google for "man chmod" will find online copies.

This is true. Another trick is to note that the user command chmod is found in section 1, and thus referred to within documentation as chmod(1), whereas the function is a system call and in section 2 and thus referred to as chmod(2). So, when you go off and google, you can get more useful results by googling chmod(2) or whatever. Any functions you'd be looking up will be in section 2 or 3, which makes it relatively easy to avoid ambiguous cases (such as printf(1) vs printf(3) &c.) . And, as noted before, when using man, you specify the section before the command.

KaeseEs
Feb 23, 2007

by Fragmaster


Seaneseor posted:

I'm running Ubuntu (Feisty) and I can't figure out how to kill the "init" process.

I initially tried "sudo kill 1", but that didn't work.

Then I read in the kill man pages that it sends the signal SIGTERM by default and that processes could catch it. That's no good, maybe "init" is catching it. It then explained that the SIGKILL signal could not be caught.

So I tried "sudo kill -s SIGKILL 1", but that didn't work either.

Is "init" catching SIGKILL? Why won't "init" die?
Why in the world do you want to kill init? If you want to turn off or reboot the computer via the terminal, try 'man shutdown'.

KaeseEs
Feb 23, 2007

by Fragmaster


marcan posted:

I regularly get hammered with SSH dictionary attacks. It doesn't mean someone is specifically targetting your machine - lots of people just do random probes against anyone with port 22 open.

Once I actually set up a (badly made) honeypot account and had an epic encounter with a (human) hacker. After an hour of going back and forth, me trying to log everything he did, him defeating my logging mechanisms (note that at no point did he ever escalate privileges beyond his dummy account - it's just that my logging systems were primitive as I had just hacked them together in about 5 minutes), I finally echoed some text to his PTY which he promptly answered in the form of comments through his bash shell (my logging system was finally working). It was very surreal, seeing everything he tried in real time (typos included). He was Spanish like I was, so I guess he got in by probing people in IP address spaces close to his. He was tunnelling through another random hacked box, of course, so I never found out where he really was connecting from. Eventually, we met up on IRC and had an interesting conversation.

I did learn something though. Next time I try my hand at a honeypot, I'll use a UML (linux-on-top-of-linux, completely isolated from the host). Even without privilege escalation, there are many not-so-good things that a random "privilegeless" account can do, if you're not very careful.


When I first installed sshd, I would get dictionary-attacked about twice a week. At first, I would run a whois on all the IPs of hackers I found by grepping through /var/log/auth.log, and send emails to the listed addresses informing them their systems had been compromised and were being used by crackers (interestingly, most of the zombified boxes were in Asian university networks). I was never really afraid of getting cracked successfully, as I disabled remote root login and used strong passwords, but the attempts were disconcerting. Then, I modified /etc/sshd_config so that my server daemon was no longer on port 22. I've had no unauthorized access attempts since.

KaeseEs
Feb 23, 2007

by Fragmaster


invid posted:

By on the fly, I meant with the "/" still mounted.

I guess its not possible, after searching around Looks like I've to get a new HDD just to mount /vz.

You don't need to do this. It's actually quite easy to resize the partition while your computer is running; any Linux LiveCD will have a copy of gPartEd, which will allow you to create/destroy/grow/shrink partitions graphically. And, a LiveCD doesn't mount your drive - it's a full OS on a disk.

So, to wrap up:

1. Download ISO of a LiveCD (here is an Ubuntu LiveCD image)
2. Burn ISO to a CD as the disk image
3. Put LiveCD in drive
4. Reboot
5. Your system will boot off the LiveCD
6. Run gPartEd to do your partitioning
7. Shut down (disk will eject at end of shutdown sequence
8. Reboot back into your system, enjoy repartitioned goodness

KaeseEs
Feb 23, 2007

by Fragmaster


Cancelbot posted:

I have a pretty big question - I find vista to be overkill for my little laptop and wish to dual boot it as Ubuntu for day to day things (coding, web, email etc) and vista for games and windows apps i cant run under ubuntu. The ubuntu partition is only going to be small (around 10-15gb) which should be plenty as my documents/music etc. are stored on external hard drives.

I really dont want to flatten and reinstall vista for this, so can the ubuntu installer repartition my HDD without severely loving everything up? I've defragged my disk and made sure all the files are compacted to the beginning of the drive. Obviously if theres a burnable set of tools that can fix my drive should the worst happen, that would be great

The Ubuntu installer will auto-magically shrink your Vista partition, make its own (and a swap partition), and install a bootloader by default. As for any scheme that dicks with partitions and/or the boot sector, back up your important data first.

Adbot
ADBOT LOVES YOU

KaeseEs
Feb 23, 2007

by Fragmaster


Kaluza-Klein posted:

Linux just blew my mind.

At my console I was in directory A, and then in my file manager I moved directory A into directory B. Then I went back to the console and did a cd .. . This put me into directory B!!!

(desktopflickrorganizer-v0.7 moved to directory ~/Programs)
patrick@Gohan ~/desktopflickrorganizer-v0.7 $ cd ..
patrick@Gohan ~/Programs $

I was fully expecting to be in my home directory after the cd. Has it always worked like this and I have just never noticed it?

The special files '.' and '..' point to the current directory and its parent, respectively. When you moved directory 'A' into directory 'B', the '.' and '..' special files were changed accordingly to point to '/path/to/B/A' and '/path/to/B', respectively. It's always been like this.

As an aside, all of the following are equivalent (in that they all change to your home directory):
code:
cd /home/yourusername/
cd ~
cd

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply