Page 1 of 2 [ 19 posts ]  Go to page 1, 2  Next

amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

27 Jul 2012, 12:36 am

I DO NOT RECOMMEND TRYING THIS IF YOUR KNOWLEDGE OF THE THE LINUX SYSTEM IS ANYTHING LESS THAN INTERMEDIATE!

UPDATE: I updated the bash script and fixed it. I am now checking what the current runlevel rule is and using that.

I wrote a bash script on my Arch Linux box to put a computer in a bootloop. I have tested it on my bsd init style Archbox and it worked like a charm! Its small and trivial but it was fun and I wanted to share. Please do not run it without knowing how to chroot and fix your run levels.

To ru W/O client/server

Code:
sudo bash /path/to/bashscript.sh


UPDATED BASH SCRIPT:
Code:
#!/bin/bash

## This function parses out the two run levels and favors the uncommented RL.
## Your current runlevel.Then pushes the result to a tmp file.               
bl=$(cat /etc/inittab |
awk '/id/ {print $1}' |
awk '!/#/ {print}');
echo -e "$bl" > tmp.txt;
echo -e "\nCurrent runlevel rule"; echo "=>" & cat tmp.txt

## Init's restart run level. What we are using for a bootloop.
runlvlid=id:6:initdefault:

## For testing purposes. To autoreset the run level.
runlvliddef=id:5:initdefault:

## Used to determine which if statement we will use.
## Parses out the runlevel number only.
runlvl=$(cat tmp.txt | awk -F":" '{print $2}')
echo -e "TOP_runlvl_no is\n=> $runlvl"

   if [ "$runlvl" == '1' ]; then
     echo -e "Current runlvl is\n=> $runlvlid"
     rm -r /etc/inittab.test2
     touch /etc/inittab.test2
     cp /etc/inittab.test /etc/inittab.test2
     arg=$runlvlid
     awk -v var=$arg '{  gsub(/id:1:initdefault:/,var,$0); print  }' /etc/inittab.test2 > /etc/inittab.test
     sudo shutdown -r now
fi

   if [ "$runlvl" == '2' ]; then
     echo -e "Current runlvl is\n=> $runlvlid"
     rm -r /etc/inittab.test2
     touch /etc/inittab.test2
     cp /etc/inittab.test /etc/inittab.test2
     arg=$runlvlid
     awk -v var=$arg '{  gsub(/id:2:initdefault:/,var,$0); print  }' /etc/inittab.test2 > /etc/inittab.test
     sudo shutdown -r now
fi

   if [ "$runlvl" == '3' ]; then
     echo -e "Current runlvl is\n=> $runlvlid"
     rm -r /etc/inittab.tmp
     touch /etc/inittab.tmp
     cp /etc/inittab /etc/inittab.tmp
     arg=$runlvlid
     awk -v var=$arg '{  gsub(/id:3:initdefault:/,var,$0); print  }' /etc/inittab.tmp > /etc/inittab
     sudo shutdown -r now
fi

   if [ "$runlvl" == '4' ]; then
     echo -e "Current runlvl is\n=> $runlvlid"
     rm -r /etc/inittab.test2
     touch /etc/inittab.test2
     cp /etc/inittab.test /etc/inittab.test2
     arg=$runlvlid
     awk -v var=$arg '{  gsub(/id:4:initdefault:/,var,$0); print  }' /etc/inittab.test2 > /etc/inittab.test
     sudo shutdown -r now
fi

   if [ "$runlvl" == '5' ]; then
     echo -e "Runlvl rule reset to\n=> $runlvlid"
     rm -r /etc/inittab.tmp
     touch /etc/inittab.tmp
     cp /etc/inittab /etc/inittab.tmp
     arg=$runlvlid
     awk -v var=$arg '{  gsub(/id:5:initdefault:/,var,$0); print  }' /etc/inittab.tmp > /etc/inittab
     echo -e "\nSetting bootloop."
     sleep 2
     sudo shutdown -r now
fi

#For testing purposes only.
   if [ "$runlvl" == '6' ]; then
     echo -e "Current runlvl is\n=> $runlvlid"
     rm -r /etc/inittab.tmp
     touch /etc/inittab.tmp
     cp /etc/inittab /etc/inittab.tmp
     arg=$runlvliddef
     awk -v var=$arg '{  gsub(/id:6:initdefault:/,var,$0); print  }' /etc/inittab.tmp > /etc/inittab
     echo "*** Defaults set. ***"
     sudo shutdown -r now
fi


There are obviously a "TON" of loop holes that I have to fix!

EDIT: You must comment out the 5th runlevel before running it the script. At least until I can fix up the script. If it doesn't work it is because run level 5 is uncommented. RE-coment it back out.

HOW TO CHROOT into your Linux box:

create a new directory to mount your hard drive on.
Code:
mkdir /mnt/root


use
Code:
sudo fdisk -l

to find your root device. I use an external HDD so external HDD's use sdb and sba. USB's use sdc. Root partitions are always sd*3 on an ext4 filesystem. Boot partition are always sd*1 and use ext2 FS. Your home directoy also uses ext4, unless you specify otherise.

So your layout should be /dev/sd*1 /boot ext2 //your boot partition
/dev/sd*2 swap swap //swap space
/dev/sd*3 / ext4 //root
/dev/sd*4 /home ext4

*NOTE: Swap is windows virtual memory counterpart.

Now mount your root device with
Code:
mount /dev/sd*3 /mnt/root


Now cd into your newly mounted root device with
Code:
cd /mnt/root


Next you'll need to mount proc, sysfs, and dev so you can mount your boot partition and chroot
use
Code:
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/


Mount your boot partition with
Code:
mount /dev/sd*1 /mnt/root/boot


CHROOT
Code:
chroot . /bin/bash


poll the dhcp server for a wired connection with
Code:
dhcpcd eth0


Now you need to restore your run levels. The script set your inittab to run level 6. Which is reboot. You want to eplace that 6 with a 5. Run level 5 is for the desktop environment.

Your innittab should be located in /etc/(For bsd init style framework). I Not sure about sysvinit and there inittab location. but i am almost certain it is in the same spot. All should be well if you did this right and you can now reboot.

I WILL SAY AGAIN -->
I DO NOT RECOMMEND TRYING THIS IF YOUR KNOWLEDGE OF THE THE LINUX SYSTEM IS ANYTHING LESS THAN INTERMEDIATE!

EDIT2: I added a server so you can do it remotely lol

SERVER CODE:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>

int main(int argc, char *argv[]) {
int sockfd, newsockfd, portno, listener, binder;
char buffer[4096];
struct sockaddr_in serv_addr, cli_addr;
struct hostent *server;
socklen_t clilen;
int s_opt, yes = 1;

   if(argc < 3) {
   printf("USAGE: %s + IP Address + Port No.\n", argv[0]);
   exit(EXIT_FAILURE);
   }

sockfd = socket(AF_INET, SOCK_STREAM, 0);
   if(sockfd < 0) {
   printf("SOCKET(-1) error --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);
   close(sockfd);
   }

   if(sockfd) {
    do {
     {
     printf("Waiting for connection...\n");
     }
    } while(!accept);
   }

s_opt = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
   if(s_opt < 0) {
   printf("SETSOCKOPT(-1) error --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);
   close(sockfd);
   }

server = gethostbyname(argv[1]);
   if(server == NULL) {
   printf("GETHOSTBYNAME(NULL) error --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);
   close(sockfd);
   }

memset(&serv_addr, 0, sizeof(serv_addr));
portno = atoi(argv[2]);
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(portno);
memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length);

binder = bind(sockfd, (const struct sockaddr *)&serv_addr, sizeof(serv_addr));
   if(binder < 0) {
   printf("BIND(-1) error --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);
   close(sockfd);
   }

listener = listen(sockfd, 20);
   if(listener < 0) {
   printf("LISTEN(-1) error --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);
   close(sockfd);
   }

clilen = sizeof(cli_addr);

newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
   if(newsockfd < 0) {
   printf("ACCEPT(-1) error --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);
   close(sockfd);
   }

      else if(newsockfd) {
      printf("=> Made a connection.\n");
      }
for(;;) {
//shutdown(sock, SHUT_WR);
ssize_t bytes_read = read(newsockfd, buffer, sizeof(buffer));
   if(bytes_read < 0) {
   printf("READ(-1) --> %s.\n", strerror(errno));
   exit(EXIT_FAILURE);   
   }

      else if (bytes_read)
      while(bytes_read > 0) {
      int eight = strlen(buffer);
        while(eight >= 8) {

         if((memcmp(buffer, "bootloop", 8)) == 0) {
         execl("/bin/bash", "bash", "/home/amboxer21/Documents/bootloop-real.sh", (char *)NULL);      
         }
            else {
            printf("Unknkown command.\n");
            break;
            }

        }   
      }
}

close(sockfd);
close(newsockfd);

return 0;
}


compile with
Code:
gcc -Wall server-bl.c -o server-bl.c


What do you think?



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 10:21 am

amboxer21 wrote:
I wrote a bash script on my Arch Linux box to put a computer in a bootloop.
But why? 8O Why abuse your root priviledges to make a machine spin on the spot when you could make it do something much more productive as a user?

In any case, you're making a stack of assumptions about init and system architecture.
For example; while parts of this may be true for your system they're certainly not a standard:
Quote:
I use an external HDD so external HDD's use sdb and sba. USB's use sdc. Root partitions are always sd*3 on an ext4 filesystem. Boot partition are always sd*1 and use ext2 FS. Your home directoy also uses ext4, unless you specify otherise.


_________________
Giraffe: a ruminant with a view.


amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 11:35 am

Well for one I love using AWK! It's such an awesome language! Parsing strings is so much fun!! I think that's why I love network coding so much! I have to manipulate strings. And the task is very tedious! If the tinies thing is wrong or one rule is not properly met, then I wont work. That's what makes it such a challenge!

There's something about AWK! It's so powerful but so freaking easy to use. If you can think it up, you can do it! It's a sys admins heaven lol

I do have productive projects I am working on though. Some GUI's, servers, etc. this was just because I was learning about unit and was itching to use AWK!

For an ext4 type FS, on an external device it is true.



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 11:49 am

Ah well if it's an excuse to play with awk. 8)
Rather too potentially destructive for my tastes, though - I'd be more included to play about with awk using my own user privileges: much safer.

amboxer21 wrote:
For an ext4 type FS, on an external device it is true.
Nope.
On your device it's true... :wink:


_________________
Giraffe: a ruminant with a view.


amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 12:07 pm

Cornflake wrote:
Ah well if it's an excuse to play with awk. 8)
Rather too potentially destructive for my tastes, though - I'd be more included to play about with awk using my own user privileges: much safer.

amboxer21 wrote:
For an ext4 type FS, on an external device it is true.
Nope.
On your device it's true... :wink:


I am not going to argue with you. You are a well established member and if your telling me I am wrong then I am probably wrong. I say this because I see you as the type of person that they wont state something unless they know it to be true. So enlighten me please :)

Yeah, its for awk purposes! I love awk! Some people say perl is better but I think its way to ugly! I love the beauty of awk!

I used awk to parse out the open ports, IP addresses and process ID's of the netstat -antp command. That was way to easy but also fun! I loved the project so much I made a GUI notification system for it. With kill buttons and stuff. Check it out here --> http://www.gtkforums.com/viewtopic.php?f=16&t=177952 the awk is very bulky. It was before I knew how to group numerous awk commands.

The great thing about that project was that I got to use all of my favorite programming tools all in one; GUI programming, awk, network programming, and C.



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 3:55 pm

amboxer21 wrote:
So enlighten me please :)
A drive is just a block device and can have any relevant partitions and filesystems on it, and it can also be installed inside the case or accessed externally. There is nothing about a device's name or location which determines what type of filesystem it will have.

Device name sequences signify nothing more than their order of appearance and that order is usually determined by the hardware. So sda, sdb, sdc, sdd are just four block devices with (at this level of naming) unknown partitions, filesystems or locations.
There is nothing about "sdc" which means it is a USB device, external or internal. It is simply the third block device available to the system. As it happens sdc on the system I'm using at the moment is an internal SATA device with two Linux partitions, one of which is bootable. (the other one would be too, if I would only get around to installing a system onto it...)

Because I have four internal disk drives sd[a-d] available, when I plug in a USB device it appears as sde - with another plugged in afterwards appearing as sdf and so on.
But that's just how my system works out.
On your system, if you already have devices sda and sdb in use, then plugging in a USB drive would normally mean it appears as sdc.
And that's just how it works out on your system. :wink:

Remember also that a USB stick (as a simple example of an external device) is normally supplied preformatted with a FAT filesystem but it can be partitioned to use whatever filesystems are required, so even on your system sdc1 could be fat32, sdc2 could be ReiserFS, sdc3 could be ext4 and so on - so actually, it's much more useful than saying an external drive is ext4.

Root partitions can be mounted from any device.
I'm currently booted from sdb9 but it could also be any of: sdb6, sdb7, sdb9, sdc1, sdc5 (if I installed something!) or sdd2, depending on what system I require. sdd2 and sdb7 are ReiserFS, sdc1 and sdb9 are ext4, sdb6 is ext3.

Quote:
Yeah, its for awk purposes! I love awk! Some people say perl is better but I think its way to ugly! I love the beauty of awk!
It's "horses for courses", really. While Perl can do what awk does it's usually easier to just use awk if those are the only functions required - but Perl is much broader in scope and can do more things than awk so it depends on how you want to play it: if something's being written that already makes heavy use of Perl there is some sense in continuing to use it instead of reaching for awk.
But that's half the fun of Linux: the toolbox is absolutely stuffed with all sorts of useful things and there is inevitably overlap so the answer to "What's the best tool?" is often "Whichever one you're most familiar with that gets the job done". :lol:


_________________
Giraffe: a ruminant with a view.


amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 4:48 pm

Quote:
A drive is just a block device and can have any relevant partitions and filesystems on it, and it can also be installed inside the case or accessed externally.

If I use a Linux distro that has a bsd init style framework(Arch Linux), I am pretty sure I understand the trivial stuff that you are not giving me credit for. I don't want to come off a jerk but I hate when I "feel" like I am being treaded like a dummy. Not saying that is/ was your intentions but that is the way you have made me feel!

I don't think you understood anything that came out of my moth lol
Quote:
There is nothing about a device's name or location which determines what type of filesystem it will have.

I never said that. You have to specify the FS type unless you are using a user friendly distro like ubuntu which specifies the FS type for you! There is an option of course to do this manually instead of the default automation.

I built my box from ground up. Even the desktop. I began with a tty console and slowly built up a stand alone openbox WM. I CHOSE TO USE AN EXT4 FS. With an ext2 type boot partition of course. Swap space included.

This i did not know. Thank you!
Quote:
Device name sequences signify nothing more than their order of appearance and that order is usually determined by the hardware. So sda, sdb, sdc, sdd are just four block devices with (at this level of naming) unknown partitions, filesystems or locations.
There is nothing about "sdc" which means it is a USB device, external or internal. It is simply the third block device available to the system. As it happens sdc on the system I'm using at the moment is an internal SATA device with two Linux partitions, one of which is bootable. (the other one would be too, if I would only get around to installing a system onto it...)



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 6:14 pm

amboxer21 wrote:
Quote:
A drive is just a block device and can have any relevant partitions and filesystems on it, and it can also be installed inside the case or accessed externally.

If I use a Linux distro that has a bsd init style framework(Arch Linux), I am pretty sure I understand the trivial stuff that you are not giving me credit for. I don't want to come off a jerk but I hate when I "feel" like I am being treaded like a dummy. Not saying that is/ was your intentions but that is the way you have made me feel!

I don't think you understood anything that came out of my moth lol
You asked for an opinion and I gave you one. Had you asked for credit I would have given you that too.
There is nothing personal in anything I've said and it puzzles me how you appear to think that there is.

Quote:
Quote:
There is nothing about a device's name or location which determines what type of filesystem it will have.

I never said that. You have to specify the FS type unless you are using a user friendly distro like ubuntu which specifies the FS type for you! There is an option of course to do this manually instead of the default automation.

I built my box from ground up. Even the desktop. I began with a tty console and slowly built up a stand alone openbox WM. I CHOSE TO USE AN EXT4 FS. With an ext2 type boot partition of course. Swap space included.
Many of the popular distros provide default and "best/most likely fit" values for things like mount points, filesystem types etc etc - but of course they can easily be changed during installation and most likely via a drop-down menu or some other simple selection method. And then there's mkfs for the plain console approach.

I mentioned some things only because you made this statement as part of some instructions on how a user can find their root device:
Quote:
I use an external HDD so external HDD's use sdb and sba. USB's use sdc. Root partitions are always sd*3 on an ext4 filesystem. Boot partition are always sd*1 and use ext2 FS. Your home directoy also uses ext4, unless you specify otherise.

I mention these again now for absolutely no other reason than they are incorrect and that your instructions are rendered meaningless by their inclusion:
so external HDD's use sdb and sba. --> on your machine.
USB's use sdc. --> on your machine.
Root partitions are always sd*3 on an ext4 filesystem --> no, they are not.
Boot partition are always sd*1 --> no, they are not.
and use ext2 FS --> not necessarily: grub has been able to load modules to support other FS's for some time now.
(this last item - that boot partitions are always sd*1 and use ext2 - is part of what I was referring to when I said "There is nothing about a device's name or location which determines what type of filesystem it will have.")


_________________
Giraffe: a ruminant with a view.


amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 6:21 pm

Btw, ext4 systems are set up to have four partitions. Boot, swap, root and home. They are always in the same order. There is never a SD* 9 or 10. That FS just wasn't made that way.

I have to read more about EXT2 when I get home.



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 6:29 pm

Sorry, but that is completely untrue - not least because ext4 is the filesystem that lives in a partition: ext4 doesn't define anything about how many partitions or what their purpose is supposed to be.
You're saying that a filesystem has partitions - it's the other way around... :wink:

What you describe is a typical default setup for any Linux system - the filesystems used are irrelevant to that (well, except swap), and the partition ordering is also irrelevant.
How do you explain I'm currently booted from sdb9, an ext4 partition?


_________________
Giraffe: a ruminant with a view.


amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 7:46 pm

Cornflake wrote:
You're saying that a filesystem has partitions - it's the other way around... :wink:

lol I just realized that :oops:

Quote:
What you describe is a typical default setup for any Linux system - the filesystems used are irrelevant to that (well, except swap), and the partition ordering is also irrelevant.
How do you explain I'm currently booted from sdb9, an ext4 partition?


Yeah, thats how Linux is set up. If you are booted from sdb9 on an ext4, you manually mounted that point or you are not using Linux.

NOTE: Everything i have said, was in regards to Linux.

Linux uses the EXT4 file systems by default.



amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 8:27 pm

Well what do you think about a program that keeps track of how many programs are running as root? Having a GUI for it, with the option to kill process that have root privs that you no longer want running? Great way for me to play around with Awk huh?



Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 8:35 pm

amboxer21 wrote:
Cornflake wrote:
You're saying that a filesystem has partitions - it's the other way around... :wink:
lol I just realized that :oops:

Cornflake wrote:
What you describe is a typical default setup for any Linux system - the filesystems used are irrelevant to that (well, except swap), and the partition ordering is also irrelevant.
How do you explain I'm currently booted from sdb9, an ext4 partition?

amboxer21 wrote:
Yeah, thats how Linux is set up.
Er no, that's just one typical setup; there is no "correct" way.
The early versions of RedHat didn't even suggest typical settings - you were expected to research them in advance and "roll your own", and the devices to mount could be and still can be practically anywhere: a different partition, a different drive - or a partition on a drive in a different country.
As requirements (especially for domestic users) have settled down into a typical requirement and distros have become much fancier over the years they do tend to use much the same partitioning arrangement - but that's not the same as saying it's how Linux is set up.

Quote:
If you are booted from sdb9 on an ext4, you manually mounted that point or you are not using Linux.
And? It still disproves your saying "There is never a SD* 9 or 10. That FS just wasn't made that way."
And "manually mounting" - you mean adding a line to fstab? I suppose that is manual, but it takes seconds and is done once during installation...
A device has a partition or partitions, and they each have a filesystem, and that device's naming and sequence has nothing to do with the filesystem being used on any of the partitions.
This is a bit old (and more than a little crazy!) but it shows just how much partitions and installations can be thrown around on Linux:
http://www.justlinux.com/forum/showthread.php?t=147959

Quote:
NOTE: Everything i have said, was in regards to Linux.
Yes, I know. :wink:

Quote:
Linux uses the EXT4 file systems by default.
No, it uses as a default whatever has been set up as a default.
Linux the OS has no default filesystem, but it does have a few filesystems that get used regularly. What does happen is that distros tend to make their default FS the current "flavour-o-the-month" which is currently ext4. Not so long ago it was ReiserFS and before that, ext2|3.


_________________
Giraffe: a ruminant with a view.


Cornflake
Administrator
Administrator

User avatar

Joined: 30 Oct 2010
Gender: Male
Posts: 68,988
Location: Over there

28 Jul 2012, 9:21 pm

amboxer21 wrote:
Well what do you think about a program that keeps track of how many programs are running as root?
I'd probably just use ps to show me root processes, if it was something I needed to know, then pipe the output to wc to get a count.
Quote:
Having a GUI for it, with the option to kill process that have root privs that you no longer want running? Great way for me to play around with Awk huh?
Meh. :wink:
It feels unnecessarily complicated to me, because it's already possible to see what's running and who owns it so therefore I can easily see what should be killed (ideally this would be nothing!) - either by name or PID. Things that run as root are usually essential system things and probably best left running. :lol:
I find that piping stuff between the core utilities such as cut, tr, head, tail and so on generally achieves what I want very quickly and since killing off root processes is something I very very rarely need to do, those tools are perfectly adequate for the job and strung together as required, "live" at a console.
Also there tend to be more structured ways of doing this (see /etc/init.d/) and with this system it's easy enough to say things like:
/etc/init.d/apache2 stop|start|restart|status for example. I think most disros use something very similar to this these days.
I simply don't require a GUI for any of this stuff so it's never occurred to me to write one. :lol:


But back onto the topic - remember that? :lol:

Having had my ISP fiddle about with their mail systems and changing servers around I've now lost as a result a very useful mail finger service that would give me a concise list of EMails waiting: from, to, date, size etc. It scratched a small itch and answered very quickly the question "I wonder if there's any mail waiting?" with the minimum of fuss, and with no GUI or even a functional mail client required.
Support for this was dropped because, I was told - it's "old school". Apparently I'm expected to use some ridiculous web interface instead. :roll:

So I'm writing a small replacement which will return the same results. Not using finger, since their fancy new systems won't do that, but using POP3 talking directly to the mail server through Telnet. There's a bit of hoop-dancing required to extract the mail header block so I can extract the from/to/subject headers, but so far it's going Ok.
That should keep me amused for a while... 8)


_________________
Giraffe: a ruminant with a view.


amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

28 Jul 2012, 10:03 pm

Cornflake wrote:
I'd probably just use ps to show me root processes, if it was something I needed to know, then pipe the output to wc to get a count.

I just used
Code:
var1=$(cat /var/log/auth.log | grep "\("sudo"\|"su"\)") | echo "$var1" | grep "COMMAND" | awk -F"=" '{print "[Process ->] "$5}'

To show me what is running with root privs. I Know i could use ps
Maybe something like
Code:
ps axf -eo pid,ppid,sid,uid,args | grep "su"

Will show me what proc has root privs. But what fun is that? Its too simple! I would take the latter just because i enjoy programming.

Cornflake wrote:
Also there tend to be more structured ways of doing this (see /etc/init.d/) and with this system it's easy enough to say things like:
/etc/init.d/apache2 stop|start|restart|status for example. I think most disros use something very similar to this these days.
I simply don't require a GUI for any of this stuff so it's never occurred to me to write one. :lol:
Yes, most distros use the sysv style init now a days. Arch is not one of them. I love Arch though! And prefer the bsd style init over sysv!

You could also make program/scripts inside of init.d at boot with a handy little tool sysv supplies called update-rc.d. It is apart of the sysv-rc package. Makes updating run levels a much more trivial task!

Cornflake wrote:
But back onto the topic - remember that? :lol:
I was so busy getting schooled by you that i almost forgot what the original post was about lol

Cornflake wrote:
Having had my ISP fiddle about with their mail systems and changing servers around I've now lost as a result a very useful mail finger service that would give me a concise list of EMails waiting: from, to, date, size etc. It scratched a small itch and answered very quickly the question "I wonder if there's any mail waiting?" with the minimum of fuss, and with no GUI or even a functional mail client required.
Support for this was dropped because, I was told - it's "old school". Apparently I'm expected to use some ridiculous web interface instead. :roll:
oo
I would have to agree! I feel the conventional mail system Linux provides is a security risk! I actually close down the incoming and outgoing mail port, on my box via iptables. Google is so much more convenient ans much more secure!

Cornflake wrote:
So I'm writing a small replacement which will return the same results. Not using finger, since their fancy new systems won't do that, but using POP3 talking directly to the mail server through Telnet.
Not so sure this is a good idea either. Telnet is not to secure. Why not write your own server and incorporate the openssl library?

Cornflake wrote:
There's a bit of hoop-dancing required to extract the mail header block so I can extract the from/to/subject headers, but so far it's going Ok.
That should keep me amused for a while... 8)
It does sound fun! I have a client chat GUI I am working on but I am being lazy left it 3 quarters finished. I am at the part where i have a UTF-8 buffer from a text entry widget inside of a scrollable window wiget but now i have to write a callback function with a signal handler and have to convert the GTK standard UTF-8 to binary. On top of that i have a select server that is also 3 qurters of the way finished. I have tons of debugging to do with that. I think once it becomes lots of work, it is no longer fun and i move on. Why wouldnt I? Its not like its my job ya know. Its just a hard core hobby lol

I was always under the assumption you were a windows user.



amboxer21
Deinonychus
Deinonychus

User avatar

Joined: 23 Jun 2011
Age: 37
Gender: Male
Posts: 350
Location: New Jersey

29 Jul 2012, 1:20 am

I love one liners!

Code:
ps axf -eo pid,ppid,sid,uid,args | awk '{print "PROC -> "$5}' | awk '!x[$0]++' | less