You are not logged in.
Pages: 1
It's nothing special so don't get your hopes up
#!/bin/bash
# use ${execi 5 pacstatus 5} in .conkyrc to display pacman information.
# the number given after pacstatus determines how many lines of history you would like shown
pacman -V | grep Pacman | cut -d " " -f 20-
echo
echo "last cmd - " `cat ~/.bash_history | grep "pacman " | tail -n1`
echo "last Sy - " `cat /var/log/pacman.log | grep sync | tail -n1 | cut -d "[" -f 2 | cut -d "]" -f -1`
echo "last Su - " `cat /var/log/pacman.log | grep "full system" | tail -n1 | cut -d "[" -f 2 | cut -d "]" -f -1`
echo
echo "last "$1" installed"
cat /var/log/pacman.log | grep installed | tail -n $1 | cut -d " " -f 4,5
echo
echo "last "$1" removed"
cat /var/log/pacman.log | grep removed | tail -n $1 | cut -d " " -f 4,5
Last edited by gazj (2010-03-06 14:31:05)
Offline
hey, that looks really nice. Will try it out as soon as I get home. Thanks!
Offline
It's nothing special so don't get your hopes up
..actually it's very nice and useful (!) script - working splendidly - thank you very much for sharing it.
Kind regards,
tami
"Possession means worries and luggage bags one has to drag along." Little My
Offline
great stuff but i have one question...
the script does not have acces to /root and the "last cmd" displays only commands typed in by normal users. how can i display root-commands in this line...
echo "last cmd - " `cat ~/.bash_history | grep "pacman " | tail -n1`
Offline
great stuff but i have one question...
the script does not have acces to /root and the "last cmd" displays only commands typed in by normal users. how can i display root-commands in this line...
echo "last cmd - " `cat ~/.bash_history | grep "pacman " | tail -n1`
You would need to change the line to this
echo "last cmd - " `cat /root/.bash_history | grep "pacman " | tail -n1`
The problem is you would need access to root's home folder to do this (it's only read access so should be fine). Use this command as root to achive this
chmod o+x /root
I haven't tested but it should work.
Or you can setup sudo then all your pacman commands can be ran as a normal user. That's how mine is currently configured.
Hope that helps
Offline
thanks, will try it in few minutes. some stuff to do here but your suggestion is exactly what i thought about. i am not very familiar with this stuff but learning.
i will post if it works without sudo, don't wanna use it.
edit: no, doesn't work.:(
Last edited by koch (2008-02-28 15:23:24)
Offline
it works, thanks again.
i thought about trying it by myself but i didn't want to make changes to /root when i am not sure about it. no unnessesary chmods without asking someone who is more familiar with this.
Offline
I wouldn't chmod 644 root's .bash_history: that way any user could read the commands you gave as root!
I'd rather add my user to root's group and chmod 640.
Or, as root
gpasswd -a username root
chmod 750 /root
chmod 640 /root/.bash_history
Last edited by carlocci (2008-02-28 16:34:19)
Offline
i was just starting to read about chmod again but this is faster, thanks.
Offline
Not quite a nice thing to state
You'd better read about chmod, it's quite easy (and it introduces you to bitmasks too!)
chmod XXX filename.file
The first X is for the owner, the second for the group, the third for all others.
You can see the owner and the group of the file with ls -l, you can change them with
chown owner:group filename.file
So what numbers can you use?
4 means read
2 means write
1 means execute
You just need to sum them up, so chmod 666 makes a file editable and readable by everyone, chmod 550 makes a file executable and readable by the owner and the group and so on.
You would be probably wondering why 1,2 and 4 have been chosen instead of 1,10,100 (which would be the most readable) or 1,3,5 (which is just another triplet).
The man page of chmod says this:
NAME
chmod - change file mode bits
If we convert them to binary
1 becomes 1
2 becomes 10
4 becomes 100
Which is just as readable and easy as 1, 10, 100 decimal.
So we need only 3 bits per user, 9 bits in total (+3 for special flags) per file.
This way the biggest number we can have is 111 binary, which is just 7 decimal and we can state the file permissions with only 3 (4 if you want to state the special flags) numbers.
Quite neat, if you consider the alternative, chmod u=rwx,g=rx,o=rx filename.file
For once, working "low level" it's easier and simpler.
Last edited by carlocci (2008-02-28 17:39:45)
Offline
I wouldn't wan to add my user to the group root, you could end up have write permissions to some of root's files or config files. If you are really concerned. Create a new group then change the permissions of roots bash_history so that the group is no longer root. Then add yourself to that new group.
There are many workarounds and none are really perfect
Offline
or rather change the owner of /root/.bash_history.. chmod root:username /root/.bash_history .. because by putting yourself in the root group, you probably open more files to yourself than you really intend on doing. this way would only allow access to this file. i am still against this whole allowing a user to read root's history, but this i guess would be one of the more secure ways..
edit: gazj you bastard!
Last edited by rson451 (2008-02-28 17:46:51)
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
or rather change the owner of /root/.bash_history.. chmod root:username /root/.bash_history .. because by putting yourself in the root group, you probably open more files to yourself than you really intend on doing. this way would only allow access to this file. i am still against this whole allowing a user to read root's history, but this i guess would be one of the more secure ways..
edit: gazj you bastard!
Great minds and all that
Offline
please share your weather forecast solution
Offline
or rather change the owner of /root/.bash_history.. chmod root:username /root/.bash_history .. because by putting yourself in the root group, you probably open more files to yourself than you really intend on doing. this way would only allow access to this file. i am still against this whole allowing a user to read root's history, but this i guess would be one of the more secure ways..
Of course.
carlocci / $ sudo find -L /etc -group root -and -perm -020
/etc/fonts/conf.d/40-generic.conf
/etc/fonts/conf.d/20-lohit-gujarati.conf
/etc/fonts/conf.d/30-amt-aliases.conf
Which are broken links, maybe some broken package I will check later.
Same for /opt and /usr... damn I have a lot of broken links!
It's true you would have access to some /dev, which is ugly actually but since he asked to read root's bash_history...
And the script isn't even real time since you would have to exit the shell to update .bash_history.
You could write a simple script/alias which calls pacman and dump the parameters you used to, eg, /var/log/pacman_history
#!/bin/bash
echo pacman $* >> /var/tmp/pacman_history
/usr/bin/pacman $*
Simply place this "script" some place in your path with a higher priority over /usr/bin.
Check pacman_history file permissions, make it readable to everyone, or better
-rw-rw---- 1 root wheel 6671 28 feb 22:56 pacman_history
Then edit the conky script to read the last line of that file,
echo "last cmd - " `tail -n1 /var/tmp/pacman_history`
Last edited by carlocci (2008-02-28 22:01:18)
Offline
@ carlocci
Thats much nicer and in real-time as you say
@ cucullus
As much as I would like to take credit it's not my work, find it here
http://ohioloco.ubuntuforums.org/showth … p?t=666842
It's really finicky to get it set up right, but the results are worth it.
Offline
first i have to say thanks to all.
i have thought about it while doing some work here at home and decided to drop the whole last-command-thing.
will have to undo the changes but...
just to be sure...
which are the default rights ( chmod...) for /root exactly?:/
arch is great. you learn a lot in short time.
Offline
first i have to say thanks to all.
i have thought about it while doing some work here at home and decided to drop the whole last-command-thing.
will have to undo the changes but...
just to be sure...
which are the default rights ( chmod...) for /root exactly?:/arch is great. you learn a lot in short time.
chmod 750 /root
Offline
Pages: 1