[131003460010] |
boot.ini
to show you the boot list.
[131003480020] |Once you pick something from that list, the bootloader's job is done, and the appropriate kernel is started from an actual partition on your drive.
[131003480030] |Grub does the same thing; the bootloader is only there to show the grub.conf
/menu.lst
list, and once you've picked something it transfers control to a regular partition.
[131003480040] |Thus grub will overwrite the NTLDR/winboot in the MBR, but not anything in a normal partition, and it knows how to transfer control to a Windows partition if you choose Windows from the boot list
[131003490010] |The only time I'd install GRUB to someplace that isn't the MBR is when on a Mac - the whole dual-booting question gets rather more complex there.
[131003490020] |In the general case, GRUB will be installed to the MBR, overwriting NTLDR, and allowing you to boot Linux or Windows.
[131003500010] |There are some confusing stuff here.
[131003500020] |First of all you need to know that there is a "Partition Boot Record" in each slice when disk is partitioned (slice=primary partition).
[131003500030] |When you format your disk, the first sector is called "bootsector".
[131003500040] |The bootsector is loaded and executed from the partition flagged as bootable.
[131003500050] |GRUB has just 512 bytes in this area, and it's called stage1.
[131003500060] |Stage 1 just loads stage2 (or1.5), and this is the file that loads the menu.lst file and other modules.
[131003500070] |Since Stage1.5 (or Stage2) loads menu.lst from a little amount of code, its filesystem-specific (need to be able to find /boot/menu.lst in your FS).
[131003500080] |Take a look here to read more.
[131003500090] |In a nutshell: Stage1 is in MBR, but GRUB isn't just stage1, everything but Stage1 is in /boot.
[131003510010] |*.ko
files), which can be given parameters when loaded into the kernel and usually live in /lib/modules/
.
[131003510030] |What's the similar arrangement for BSD/OSX?
[131003510040] |For example, I've just installed MacFUSE and have hard time understanding what exactly did the installer put into my system.
[131003520010] |I'm not sure about other BSD, but OSX have kernel extensions (known as kext
).
[131003520020] |Kexts live in /System/Library/Extensions/
.
[131003520030] |Each of them is a folder, containing device description and instruction (those that makes a driver).
[131003520040] |Things in a kext need suitable file permissions (generally belong to user 0:0
with mask 755
) for it to work.
[131003520050] |After a kext is in place, the OS will automatically load it on reboot (although sometimes instantly).
[131003520060] |Occasionally you need to clear the kext cache (rm -r /System/Library/Extensions/Caches/
) before the new kext will work correctly.
[131003530010] |ps aux | grep java
ps -fp $(pgrep -d, -x java)
or you might use htop or top and search for java
[131003550010] |You want the wide output option "w".
[131003550020] |Using it three times will allow unlimited width.
[131003550030] |ps auxwww
[131003560010] |A GUI alternative to Ksysguard is qps.
[131003560020] |It's perhaps less visually appealing that ksysguard, but it shows a lot more information, including the whole command line.
[131003570010] |df
it returned the location of the device as
[131003590040] |after that I ran
[131003590050] |and then to install grub 2
[131003590060] |I had to use --force additionally, the example on the site did not.
[131003590070] |Then I did
[131003590080] |The site gave a link to download a copy of grub.cfg to the /boot/grub directory on my USB drive.
[131003590090] |The link was
[131003590100] |After that I edited grub.cfg to reflect the iso's on my USB drive.
[131003590110] |I found that in the different iso's, vmlinuz and initrd were located in a different directory.
[131003590120] |I was able to get all three to start the boot process; but, only Ubuntu to actually load.
[131003590130] |If I figure out what I need to get the other two to finish loading, I will add that later.
[131003590140] |I have not tried any other iso's just these three.
[131003600010] |cut(1)
do what you want.
[131003640020] |I believe you are correct in believing that if you have mixed whitespace delimiters that the best alternative is awk(1)
.
[131003650010] |You could preprocess your data with something like tr -s ' ' '\t'
.
[131003650020] |But you wouldn't get any benefit unless your lines were very long.
[131003650030] |(How long? measure and find out.)
[131003660010] |gcc
compiler for finding include files are explained at: http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html
[131003700020] |A quick command-line trick to find out where an include file comes from is the following:1
[131003700030] |Then, if you look at the unistd.preprocessed
file, yo*emphasized text*u will notice lines like:
[131003700040] |These tell you that the following block of lines (until the next # number ...
line) come from file /usr/include/unistd.h
.
[131003700050] |So, if you want to know the full list of files included, you can grep for the # number
lines:
[131003700060] |On my Ubuntu 10.04 / gcc 4.4.3 system, this produces:
[131003700070] |1 Note: The search path for include files is modified by the -I
command-line option; so, you should add any -I path
arguments to the gcc
invocation.
[131003700080] |Also, if you are compiling a C++ source, you should substitute -x c
with -x c++
.
[131003710010] |~/.wine
and it will not delete most of your settings.
[131003760010] |Malware has been known to work via wine... but from memory it has mostly been limited to what you mount in wine, and is not capable of working once wine is off.
[131003760020] |Whatever you do, do not mount /
in wine.
[131003760030] |Anything you mount could get infected, so I recommended mounting as little as possible, lest your mp3's become viral.
[131003770010] |sudo
; my password is accepted.
[131003770030] |But whenever I try to do su
from a shell, it fails with:
[131003770040] |su: incorrect password
[131003770050] |What can the problem be?
[131003780010] |su
means substitude user and if its called without any arguments you will become the superuser.
[131003780020] |Therefore you have to enter the users password.
[131003780030] |This is some kind of unhandy if many people need to use commands for the system administration or similar stuff with extended user rights.
[131003780040] |You just don't wan't that people have unlimited rights by sharing all the same root password.
[131003780050] |The solution for this kind of problems is sudo
("substitude user do").
[131003780060] |This will allow you to specifiy the commands someone can invoke and define the permissions.
[131003780070] |For sudo
you don't have to enter the root password, but the password of the user who tries to invoke a sudo command.
[131003780080] |Some distributions have the root user disabled for security reasons.
[131003780090] |This could be one explanation why you aren't able to use su.
[131003780100] |You could try to skip the password by using sudo: sudo su
;-)
[131003790010] |The su command without options, will default to allow you to become the root user.
[131003790020] |It isn't asking for your password, but the root password.
[131003790030] |The sudo command always asks for your password.
[131003800010] |~/.gnome2
or ~/.kde
.
[131003830060] |To tell the system, where the location of your new home directory is, you should just automount your pendrive to /home/username or simply change the location of your users home directory in /etc/passwd
to your pendrives mountpoint.
[131003830070] |If this doesn't fit your question, please be more specific. :-)
[131003840010] |Have you considered using Ubuntu One to synchronize your stuff?
[131003840020] |I'd be afraid to keep my home directory on a single pendrive, I've lost too many of those.
[131003850010] |sudo apt-get build-dep
[131003880010] |/proc/cpuinfo
, so there is a lot of redundant information here.
[131003890020] |To get an overview of how many cpus and/or cores you have, do something like this:
[131003890030] |This is run on my single-chip, dual-core computer.
[131003890040] |So I have two cores, numbered 0 and 1, but both of them belong to the physical cpu 0.
[131003890050] |Computer guys like to count from 0, remember.
[131003890060] |Here's the output from a dual-cpu, single-core system:
[131003890070] |So I have two CPUs, but since no cores are specified I know that each processor chip has a single core.
[131003890080] |Something a bit more interesting:
[131003890090] |Here's my dual-cpu dual-core system.
[131003890100] |I have "processors" 0-3, and each lives on processor 0 or 1, as core 0 or 1.
[131003890110] |You get the idea.
[131003890120] |All that said, I suspect you have a dual-cpu quad-core system, with processors 0 through 7.
[131003900010] |Number of processors: Please note that numbering starts from 0 so if I have processor 1 I have at least 2 of them
[131003900020] |Bounding to threads Threads will not be bound to CPU's (unless you do tricks by using cpulimit &co. - in most cases you shouldn't).
[131003900030] |Assuming that you have configured kernel with 1000Hz and there is no I/O the context switch is done 1000 times per second.
[131003900040] |Now in my 2 Processors setup I have around 300 threads running at this moment which means that 6.(6) slots will be allocated per process.
[131003900050] |It is safe to assume that in any second each process will occupy the both core.
[131003900060] |Given - the staircase algorithms, I/O make it not necessary true but each thread at one second may be on both cores - as well as running nowhere as it is waiting (so it is not bounded to any core).
[131003900070] |Hyperthreading I guess that you have 4 core Intel iX with hyperthreading (unless you have dual processor machine).
[131003900080] |Hyperthreading works by emulating a separate core.
[131003900090] |So if process is waiting on one core for I/O it can switch to executing another - which of course complicate matter further.
[131003910010] |mount
command: it keeps track of its actions in /etc/mtab
, so running mount
under chroot
will update a different mtab
file.
[131003940030] |You could also use mount --bind /proc ./my_chroot/proc
.
[131003940040] |As far as I know, there is no practical difference between that and mount -t none proc ./mychroot/proc
: you can mount the proc
filesystem as many times as you like, and mount options are ignored. mount --bind
will prevent you from unmounting the filesystem on /proc
outside the chroot, but that should never happen anyway.
[131003940050] |As an aside, I would recommend mount -r proc proc …/proc
because seeing proc
in the device field in a mtab
or in /proc/mounts
is clearer than seeing none
.
[131003950010] |man nohup
help disown
Ctrl-Z
, pull it into the background with bg
and then disown
it, like this:
[131003990010] |xrandr
too) but I'd like to do it in the linux console.
[131003990050] |I have looked at vbetool but I am not sure it is the right way (the commands I tried did not work anyway).
[131003990060] |I have a nvidia card.
[131004000010] |I can't try it right know, but I found this answer to your question: fbgetty /dev/tty8 /dev/fb0
fbgetty /dev/tty9 /dev/fb1
[131004000020] |Where:
[131004000030] |- /dev/tty8/9/n are the terminals you want to move
[131004000040] |- /dev/fb0/1/v are the framebuffer devices you want to use ... it should switch between your outputs
[131004000050] |Solution is taken from this forum thread: http://www.linuxforums.org/forum/debian-linux/96430-move-tty-second-monitor.html
[131004010010] |http.conf
location is configured correctly.
[131004010050] |It works -- I can open up a browser and navigate to localhost
and see the "It works" message.
[131004010060] |But how does one goes about adding Apache into Ubuntu's startup so I won't have to do:
[131004010070] |all the time?
[131004010080] |Can somebody explain how does one goes into adding programs to the Ubuntu startup (10.10 64 bit)?
[131004020010] |Here is a good resource, quite close to what you ask for.
[131004020020] |Basically to make apache2 start automatically you need to run
[131004020030] |This will make the startup script start the service located in /etc/init.d/apache2
after booting up.
[131004020040] |Beforehand, you need to make an init script and put it in /etc/init.d/
.
[131004020050] |In your case
[131004020060] |may be good enough.
[131004030010] |The easiest way is to take the Apache startup script in Ubuntu's Apache package, and replace /usr/sbin/apachectl
by /server/apache/bin/apachectl
.
[131004030020] |If it's a learning exercise, you have several options (from most flexible to least flexible):
[131004030030] |/etc/init/my_apache.conf
.
[131004030050] |Given the state of Upstart documentation, I recommend reading existing examples and the man pages in parallel./etc/init.d
that starts, stops, restarts or reloads the Apache configuration depending on whether its first (and sole) argument is start
, stop
, restart
, or reload
(with force-reload
as an alias for reload
).
[131004030070] |To have the script start on boot, run update-rc.d
.
[131004030080] |See also the Ubuntu Bootup Howto./etc/rc.local
./var/log
directory where a bunch of programs store their logs.
[131004080010] |Assuming enough naïveté on the side of your attacker, you can simply throw script -qft $USER-$$ 2> $USER-$$-time
into his/your appropriate login script to monitor his or her terminal interactions and replay with the appropriate scriptreplay commands.
[131004080020] |To monitor file-level access, I recommend attaching an strace -fe open
with appropriate logging to the sshd and filtering for login sessions (or maybe it's better to just do this from .
[131004080030] |Warning: Huge outputs, since doing anything on a modern system touches a lot of files.
[131004080040] |If you just want to monitor specific files, have a look at auditd and its support infrastructure.
[131004080050] |Sessions and login attempts can be gathered from syslog as per other answers.
[131004090010] |You could use in-kernel mechanism inotify
for monitoring accessed files.
[131004090020] |First you should check if inotify
is turned on in kernel:
[131004090030] |Next thing to do is install inotify-tools
.
[131004090040] |Instructions for various distributions you could find at project page - it should be in repositories of all major distributions.
[131004090050] |After that inotify is ready to work:
[131004090060] |(m
= do not exit after one event, r
= recursive, q
= quiet)
[131004090070] |For example - output after ls /home/pbm
[131004090080] |Important thing is to properly set directories for watch:
[131004090090] |/
recursively - there is a lot of read/write to /dev
and /proc
/proc/sys/fs/inotify/max_user_watches
there is configuration option that shows how manu files could be watched simultaneously.
[131004090120] |Default value (for Gentoo) is about not so high, so if you set watcher to /home/
you could exceed limit.
[131004090130] |You could increase limit by using echo
(root access needed).
[131004090140] |But before that you should read about consequences of that change.
[131004090150] |Options that could be interesting for you:
[131004090160] |-d
= daemon mode -o file
= output to file--format
= user-specified format, more info in man inotifywait
-e EVENT
= what event should be monitored (for example access
, modify
, etc, more info in man
)/var/log
(some systems use a different location such as /var/logs
or /var/adm
).
[131004100050] |Under a normal configuration, all logins and mounts are recorded, amongst others.
[131004100060] |If you're worried about logs being erased, you can set up remote logging (how to do this depends on the syslog implementation, but it's generally one or two lines to change in a configuration file on the sender and on the receiver).
[131004100070] |If you or your distribution hasn't disabled this feature, every file has an access time (“atime”) which is updated whenever the file is read.
[131004100080] |(If the filesystem is mounted with the noatime
or relatime
option, the atime is not updated.)
[131004100090] |The atime can be faked with touch -a
, but this updates the ctime, so it leaves a trace.
[131004100100] |(Even root cannot directly remove this trace, you need to bypass the filesystem code.)
[131004100110] |Various programs have a session history.
[131004100120] |It's easy to remove or fake, if the intruder remembered to do so.
[131004100130] |Bash keeps ~/.bash_history
, browsers tend to write lots of stuff in their profile directory, and so on.
[131004100140] |You may also find telling errors or warnings in ~/.xsession-errors
or /var/log/Xorg.0.log
or other system-dependent location.
[131004100150] |Many unices have a process accounting¹ feature.
[131004100160] |See for example the GNU accounting utilities manual, the entry in the FreeBSD handbook or the Linux howto or the Solaris guide.
[131004100170] |Once enabled, it records what user launched what process when (it logs execve
calls), and perhaps a little more.
[131004100180] |There's a lot of interesting information it doesn't log, such as the files accessed by the process.
[131004100190] |If you want to monitor all accesses to a filesystem, you can provide it through loggedfs.
[131004100200] |It's very easy to notice if the guy thinks to look.
[131004100210] |There are more comprehensive logging programs, but they might require additional kernel support.
[131004100220] |On Solaris, FreeBSD, NetBSD and Mac OS X, there is dtrace (there's a Linux port in progress but I don't know if it's reached a usable stage).
[131004100230] |You can also trace specific processes through an interface to the ptrace
system call, for example strace
on Linux; it may induce a noticeable slowdown.
[131004100240] |¹ Something that's not in Wikipedia?
[131004100250] |Nah, that's crazy talk.
[131004110010] |unzip
doesn't do this, because the UNIX way is to do one thing and do that well, not handle all crazy special cases in every tool.
[131004120020] |Thus, you need to use the shell (which does the job of "tieing things together" well).
[131004120030] |This makes it a programming question, and since ALL possible programming questions have been answered on StackOverflow, here: How do you recursively unzip archives in a directory and its subdirectories from the Unix command-line?
[131004130010] |This will extract all the zip files into the current directory, excluding any zipfiles contained within them.
[131004130020] |Although this extracts the contents to the current directory, not all files will end up strictly in this directory since the contents may include subdirectories.
[131004130030] |If you actually wanted all the files strictly in the current directory, you can run
[131004130040] |Note: this will clobber files if there are two with the same name in different directories.
[131004130050] |If you want to recursively extract all the zip files and the zips contained within, the following extracts all the zip files in the current directory and all the zips contained within them to the current directory.
[131004140010] |As far as I understand, you have zip archives that themselves contain zip archives, and you would like to unzip nested zips whenever one is extracted.
[131004140020] |Here's a bash 4 script that unzips all zips in the current directory and its subdirectories recursively, removes each zip file after it has been unzipped, and keeps going as long as there are zip files.
[131004140030] |A zip file in a subdirectory is extracted relative to that subdirectory.
[131004140040] |Warning: untested, make a backup of the original files before trying it out or replace rm
by moving the zip file outside the directory tree.
[131004140050] |The script will also work in zsh if you replace the shopt
line with setopt nullglob
.
[131004140060] |Here's a portable equivalent.
[131004140070] |The termination condition is a little complicated because find
does not spontaneously return a status to indicate whether it has found any files.
[131004140080] |Warning: as above.
[131004150010] |The easiest way is to use atool: http://www.nongnu.org/atool/ It is a very good script that use zip, unzip, tar, rar etc. programs to extract any archive.
[131004150020] |Use atool -x package_name.zip
to unzip them all or if you wanna use it in directory with many zip files use simple for
loop: for f in *; do atool -x $f; fi
(you will have to cd
into desired directory with zip files before you use this).
[131004160010] |You'll want to be careful automatically unzipping zip files inside of zip files:
[131004160020] |http://research.swtch.com/2010/03/zip-files-all-way-down.html
[131004160030] |It's possible to concoct a zip file that produces a zip file as output, which produces a zip file as output, etc etc etc.
[131004160040] |That is, you can make a zip file that's a fixed oint of "unzip" the program.
[131004160050] |Also, I seem to recall people making zip files that would "explode", that is a very small zip file would unzip to multi-gigabytes of output.
[131004160060] |This is a facet of the method of compression.
[131004170010] |eth0
(wired) and wlan0
(wireless).
[131004170030] |Every time the computer boots it tries to bring up both.
[131004170040] |Most often when there is a LAN cable I don't need wlan0
, and vice versa, so this looks like a waste.
[131004170050] |I want to stop the interfaces from being brought up automatically so that I can bring up the one that I need, if at all.
[131004170060] |According to the Gentoo Handbook I need to run
[131004170070] |to have eth0
up every time the system boots and I assume the same thing goes for wlan0
.
[131004170080] |However the result of
[131004170090] |does not contain either eth0
or wlan0
.
[131004170100] |So the question is, who is bringing up the 2 interfaces?
[131004170110] |How can I stop that?
[131004180010] |Some services requires network service (i.e. they use network ;) ).
[131004180020] |The RC_NET_STRICT_CHECKING
variable from /etc/conf.d/rc
determines when the service is 'up'.
[131004180030] |Particulary the "no" setting seems to describe something similar to what you want:
[131004180040] |I guess that configuration you described is particulary useful in mobile enviroment and, personally, I prefere to use net-misc/networkmanager to manage network for me and disable Gentoo script managing (which is mostly suitable for servers and have no proper handling of hibernations, dynamic configuration etc.).
[131004190010] |echo '
Ctrl+V Tab ' | od -t x1
Enter. 0000000 09 0a
(i.e. at position 0, two characters, a tab and a newline) is the expected output.
[131004220070] |I don't expect this to be the issue.
[131004220080] |If you can't get a comfortable environment, you could try doing more things remotely, using your local machine for interaction as much as possible.
[131004220090] |This has its ups and downs.
[131004220100] |/os390hostname:/path/on/remote/machine
, you get completion).
[131004220120] |You can also use Eshell to get a remote shell interface (an Emacs built-in shell); if you change to a remote directory (cd /os390hostname:/path/on/remote/machine
), the external commands you launch will be executed on the remote machine.
[131004220130] |If you need to run commands as root, Tramp (and Eshell which is based on it) can combine ssh with su or sudo.ESC
in normal mode, or pressing h
in on col 0.
[131004260010] |To disable the bell altogether, you need to
[131004260020] |set visualbell
(= set vb
);set t_vb=
'visualbell'
, but not very clearly.)
[131004260050] |¹ Even with novisualbell
, you might see a visual bell if vim emits a bell control sequence (usually \a
) and the terminal is configured to flash rather than make a sound.
[131004270010] |avahi-daemon
.
[131004290030] |I tried to modify the file /etc/default/avahi-daemon
, setting the AVAHI_DAEMON_DETECT_LOCAL=0
instead of 1
, but when I connect to a network it starts anyway; is there no way to stop it?
[131004290040] |I am trying to stop it because every time I connect to a network it and dhclient
starts it gives my NIC another address so I cannot access the network.
[131004290050] |I'm on a Debian machine.
[131004310010] |You can use rcconf
to disable it starting it from boot or you can manually remove it from autostartup with;
[131004310020] |Only root can do this so use sudo
if you are not root.
[131004320010] |exit
command terminates the subshell instead of the main script which is required.
[131004330040] |It is part of a much larger script to configure policy routing, and it is halt the execution if it detects a condition that will cause routing to fail.
[131004330050] |So one of the suggested alternatives is to use a command like this to avoid the subshell.
[131004330060] |So it seems to me that I should also be able use a command like this to avoid the subshell and still get the output from the program I want.
[131004330070] |Unfortunately, using that command results in this error.
[131004330080] |I get really confused since this does work.
[131004330090] |I could save the output of that command to a temporary file, and use redirect the on the temporary file, but I wanted to avoid doing that.
[131004330100] |So why is the redirection giving me an error, and do I have any options other then creating a temporary file?
[131004340010] |You missed a <
.
[131004340020] |Should be:
[131004340030] |Think of <(sysctl -a 2>/dev/null | grep '\.rp_filter')
being a file.
[131004350010] |openssl rand 16
gives you 128 bit GUIDs.
[131004360030] |Use 32 if you want 256 bit GUIDs.
[131004370010] |Short Perl script below - the use of cat to get the uuid isn't the cleanest/fastest way to code it, but it keeps the command short:
[131004370020] |The above uses a file in /proc on linux as a source of uuids:
[131004380010] |Similar to bahamat answer, but generates actual UUIDs.
[131004380020] |UUIDs have some reserved bits that are used to determine the version and variant used.
[131004380030] |There are currently 5 types of UUIDs defined, random UUIDs, as you asked, are version 4.
[131004380040] |You will note that version 4 UUIDs have this format:
[131004380050] |Also, this version doesn't cause damage in case the UUID generation fails.
[131004380060] |Using /proc/sys/kernel/random/uuid:
[131004390010] |gpg
?
[131004390030] |It accepts only file as input argument.
[131004390040] |But I need to encrypt a lot of files on external HDD.
[131004400010] |I just saw the option --multifile
on the manpage:
[131004400020] |This modifies certain other commands to accept multiple files for processing on the command line or read from STDIN with each filename on a separate line.
[131004400030] |This allows for many files to be processed at once. --multi‐ file may currently be used along with --verify, --encrypt, and --decrypt.
[131004400040] |Note that --multifile --verify may not be used with detached signatures.
[131004400050] |What you are specifically looking for is --encrypt-files
and, again the manpage:
[131004400060] |Identical to --multifile --encrypt.
[131004410010] |Why not tar
the files to be encrypted and then encrypt the tarball?
[131004420010] |startx
to start the GUI.
[131004420040] |I have entries in ~/.xinitrc
for my GUI sessions.
[131004420050] |Right now I have xmonad in there, but sometimes I want to run a GNOME session, and sometimes a KDE session.
[131004420060] |I used to edit ~/.xinitrc
for that purpose, but I think there should be a more elegant way (something like using alternate configurations).
[131004420070] |However, I can't find anything in man startx
or man xinit
.
[131004420080] |I plan to have several configuration files (one for each GUI session), and then tell startx
to load them when I want.
[131004420090] |How can I do that?
[131004430010] |According to the xinit
man page that I read, xinit
(and thereby startx
) looks in its command line parameters for a client program to run.
[131004430020] |If it doesn't find one, it runs ~/.xinitrc
instead.
[131004430030] |So you should be able to write
[131004430040] |and it will do what you want.
[131004430050] |You will need to provide a path, though, and not just a filename.
[131004430060] |In my testing, startx ./my_xinitrc
worked but startx my_xinitrc
did not.
[131004440010] |proc(5)
man page tells me that /proc/$pid/mem
“can be used to access the pages of a process's memory”.
[131004440030] |But a straightforward attempt to use it only gives me
[131004440040] |Why isn't cat
able to print its own memory (/proc/self/mem
)?
[131004440050] |And what is this strange “no such process” error when I try to print the shell's memory (/proc/$$/mem
, obviously the process exists)?
[131004440060] |How can I read from /proc/$pid/mem
, then?
[131004450010] |/proc/$pid/maps
/proc/$pid/mem
shows the contents of $pid's memory mapped the same way as in the process, i.e., the byte at offset x in the pseudo-file is the same as the byte at address x in the process.
[131004450030] |If an address is unmapped in the process, reading from the corresponding offset in the file returns EIO
(Input/output error).
[131004450040] |For example, since the first page in a process is never mapped (so that dereferencing a NULL
pointer fails cleanly rather than unintendedly accessing actual memory), reading the first byte of /proc/$pid/mem
always yield an I/O error.
[131004450050] |The way to find out what parts of the process memory are mapped is to read /proc/$pid/maps
.
[131004450060] |This file contains one line per mapped region, looking like this:
[131004450070] |The first two numbers are the boundaries of the region (addresses of the first byte and the byte after last, in hexa).
[131004450080] |The next column contain the permissions, then there's some information about the file (offset, device, inode and name) if this is a file mapping.
[131004450090] |See the proc(5)
man page or Understanding Linux /proc/id/maps for more information.
[131004450100] |Here's a proof-of-concept script that dumps the contents of its own memory.
[131004450110] |/proc/$pid/mem
mem
pseudo-file of another process, it doesn't work: you get an ESRCH
(No such process) error.
[131004450130] |The permissions on /proc/$pid/mem
(r--------
) are more liberal than what should be the case.
[131004450140] |For example, you shouldn't be able to read a setuid process's memory.
[131004450150] |Furthermore, trying to read a process's memory while the process is modifying it could give the reader an inconsistent view of the memory, and worse, there were race conditions that could trace older versions of the Linux kernel (according to this lkml thread, though I don't know the details).
[131004450160] |So additional checks are needed:
[131004450170] |/proc/$pid/mem
must attach to the process using ptrace
with the PTRACE_ATTACH
flag.
[131004450180] |This is what debuggers do when they start debugging a process; it's also what strace
does to a process's system calls.
[131004450190] |Once the reader has finished reading from /proc/$pid/mem
, it should detach by calling ptrace
with the PTRACE_DETACH
flag.ptrace(PTRACE_ATTACH, …)
will stop the target process (it sends a STOP
signal), but there is a race condition (signal delivery is asynchronous), so the tracer should call wait
(as documented in ptrace(2)
).ptrace
, but the observed process must be stopped, or the read will still return ESRCH
.
[131004450230] |In the Linux kernel source, the code providing per-process entries in /proc
is in fs/proc/base.c
, and the function to read from /proc/$pid/mem
is mem_read
.
[131004450240] |The additional check is performed by check_mem_permission
.
[131004450250] |Here's some sample C code to attach to a process and read a chunk its of mem
file (error checking omitted):
[131004450260] |I've already posted a proof-of-concept script for dumping /proc/$pid/mem
on another thread.
[131004460010] |When you execute cat /proc/$$/mem
the variable $$
is evaluated by by bash which inserts its own pid.
[131004460020] |It then executes cat
which has a different pid.
[131004460030] |You end up with cat
trying to read the memory of bash
, its parent process.
[131004460040] |Since non-privileged processes can only read their own memory space this gets denied by the kernel.
[131004460050] |Here's an example:
[131004460060] |Note that $$
evaluates to 17823.
[131004460070] |Let's see which process that is.
[131004460080] |It's my current shell.
[131004460090] |Here again $$
evaluates to 17823, which is my shell. cat
can't read my shell's memory space.
[131004470010] |su
, so you need to find out the user running su
's parent process:
[131004510020] |But you shouldn't be doing sudo su -
if your version of sudo is not too old to have sudo -i
.
[131004510030] |Sudo sets the environment variable SUDO_USER
to the name of the user who ran sudo.
[131004510040] |You won't see it with sudo su -
because su -
scrubs the environment.
[131004520010] |Run command "who am i"
it will return you something like that:
[131004520020] |In bold "gladimdim" is the user which was initially logged to system.
[131004530010] |input_get_keycode(data->input_dev, scancode, &keycode);
When I was compiling I was getting errors that there's no function with that prototype.
[131004530030] |Looking into the input/input.c
source code, this is the definition of input_get_keycode
:
[131004530040] |I tried to look online, and I found a couple obscure references to changing the kernel to be able to deal with large keymaps better, and apparently this function was changed to better handle that.
[131004530050] |Looking at an older source from input/input.c, the input_get_keycode
function was defined as
[131004530060] |My question is, when was this changed.
[131004530070] |Is there notes on the change?
[131004530080] |I'm building the ubuntu natty
kernel from git which is from my understanding from the 2.6.37-rc3
branch.
[131004530090] |Is this a ubuntu specific change?
[131004530100] |Or is this a change in the mainline kernel.
[131004530110] |I also have the maverick
source from git which has the old style (3 input) function.
[131004540010] |If you are working on a kernel module, I very much recommend that you get a git tree.
[131004540020] |Obviously Linus's tree is mandatory - I also get the stable trees.
[131004540030] |Since you are working on Ubuntu, I'd check to see if they have a tree with their changes you can pull from.
[131004540040] |Using the git tree, I was able to checkout master
and run git blame drivers/input/input.c
to see that the function signature for input_get_keycode
was last changed in commit 8613e4c2
.
[131004540050] |Running git show 8613e4c2
gives me the commit message for that change (the notes that you wanted) as well as the patch that implements the change.
[131004540060] |I can see that the change was made on 2010-09-09.
[131004540070] |Starting up gitk
(a graphical git viewer) and telling it to go to that commit I can see that the commit precedes v2.6.37-rc1, telling me it was merged into that release.
[131004540080] |Following the branch up to when Linus merged it, I can see it was merged on 2010-10-26 in commit 3a99c631.
[131004540090] |This is all mainline without looking at Ubuntu patches, so it looks like the change has nothing to do with Ubuntu.
[131004550010] |strings
first:-
[131004570010] |If you have poppler-utils
installed (default on Ubuntu Desktop), you could "convert" it on the fly and pipe it to grep
:
[131004570020] |This won't create a .txt file.
[131004580010] |gpdf might be what you need if you're using Gnome!
[131004580020] |Check this in case you're not using Gnome.
[131004580030] |It's got a list of CLI pdf viewers.
[131004580040] |Then you can use grep
to find some pattern.
[131004580050] |Hope that helps.
[131004590010] |No.
[131004590020] |A pdf consists of chunks of data, some of them text, some of them pictures and some of them really magical fancy XYZ (eg. .u3d files).
[131004590030] |Those chunks are most of the times compressed (eg. flat, check http://www.verypdf.com/pdfinfoeditor/compression.htm).
[131004590040] |In order to 'grep' a .pdf you have to reverse the compression aka extract the text.
[131004590050] |You can do that either per file with tools such as pdf2text
and grep the result, or you run an 'indexer' (look at xapian.org or lucene) which builds an searchable index out of your .pdf files and then you can use the search engine tools of that indexer to get the content of the pdf.
[131004590060] |But no, you can not grep
pdf files and hope for reliable answers without extracting the text first.
[131004600010] |scp
stands for secure copy and it transfers over SSH.
[131004660040] |There is also sftp
[131004660050] |I guess the only real advantage to using this is that you can transfer multiple files without typing in your SSH password all the time.
[131004660060] |(If you don't use a keyring that is)
[131004660070] |If you're going to be regularly transferring files take a look at rsync
.
[131004660080] |A simple usage of rsync
might look like:
[131004660090] |But take a look at the man page as there are tons of options.
[131004660100] |Finally, there is a sshfs
.
[131004660110] |With this method you can mount an SSH server to your local filesystem like any other filesystem, then you can just copy files into it.
[131004670010] |Technically, the answer to your question is that you must specify where the file is.
[131004670020] |There is no magic.
[131004670030] |For instance with SCP (which uses the SSH protocol) you would specify username@systemname:pathtofile
[131004670040] |SCP then logs in to the system that you specify using the username and follows the path that you specify to find the file.
[131004680010] |user@local.com
.
[131004680040] |I'm given credentials to a remote mail server mailbox, e.g. other@remote.com
.
[131004680050] |What command line incantation on my local box would connect me to SMTP server at remote.com
providing username and password and send mail through it?
[131004680060] |I've read sendmail
and smtp
manpages but that didn't give me any clue.
[131004690010] |You will need to have Postfix relay the messages to the remote server.
[131004690020] |This will require a change to the Postfix configuration.
[131004690030] |You'll need to enable Postfix's SASL authentication to handle the authentication.
[131004690040] |Once configured, you can use your local SMTP server as you did with local addresses, and the local server will relay them on the the remote server.
[131004700010] |Actually, Postfix turned out to be irrelevant to my problem.
[131004700020] |Using it would be an overkill for this task: it requires per-host configuration, where per-user would do.
[131004700030] |I figured out msmtp
is well enough for my task.
[131004710010] |/proc/acpi/
if you have some entries like this one : /proc/acpi/video/GFX0/LCDD/brightness
[131004730030] |If you find it, try to set a value maybe like this :
[131004740010] |Add "acpi_osi=Linux" to loader
[131004740020] |Example:
[131004750010] |-N
mode but doesn't elaborate it much and says that it should be the default mode.
[131004750040] |My questions:
[131004750050] |-N
mode?.vimrc
?vim -N
sets Vim in "nocompatible" mode, which drops strict backwards compatibility with the original vi
in favor of better features.
[131004760020] |Unless you know that you need (or want) backwards compatibility, it's better to go with the features.
[131004760030] |If you have a .vimrc
file in the first place, Vim will by default put you in nocompatible mode, but the command set nocompatible
will seal the deal.
[131004760040] |See the following Vim help topics for more info:
[131004770010] |Broad_hapmap3_r2_Affy6_cels_excluded.tgz
in any subdirectory.
[131004810100] |For a recursive traversal in zsh or bash ≥4, you can use **
in patterns.
[131004810110] |In zsh:
[131004810120] |In bash ≥4:
[131004810130] |You can even use find if you don't want a recursive traversal, though it's not the most convenient way then.
[131004820010] |%Y.%m.%d %H:%M
will give me 2011.02.22 10:19 , I need something that yields 2011.02.22 10:15 in the time span from 10:15 to 10:29.
[131004830010] |You can get the current unix timestamp with date "+%s"
, find the current quarter-hour with some simple math (my example is in bash
) and print it back with a better format with date
:
[131004830020] |The @
syntax to set the current date and time from a timestamp is a GNU extention to date, if it don't works on your OS, you can do the same like this :
[131004840010] |Am not sure about your exact requirement.
[131004840020] |However, if you want to generate the time after 15 min, then you can use something like date -d '+15 min'
.
[131004840030] |Output is shown below:
[131004850010] |If you can live with calling date two times, this one works in bash on Solaris:
[131004850020] |Edited on behalf of the comment to:
[131004860010] |The following methods make it unnecessary to call date
twice.
[131004860020] |A system call's overhead can make a "simple" command 100 times slower than bash doing the same thing in its own local environment.
[131004860030] |UPDATE Just a quick mention about my above comment: "100 times slower".
[131004860040] |It can now read "500 times slower"...
[131004860050] |I recently fell (no, walked blindly) into this very issue. here is the link: Fast way to build a test file
[131004860060] |or
[131004860070] |Both versions will return only
[131004860080] |Here is the first one with a TEST loop for all 60 values {00..59}
[131004870010] |Here's a way to work on dates in the shell.
[131004870020] |First call date
to get the components, and fill the positional parameters ($1
, $2
, etc) with the components (note that this is one of these rare cases where you do want to use $(…)
outside of double quotes, to break the string into words).
[131004870030] |Then perform arithmetics, tests, or whatever you need to do on the components.
[131004870040] |Finally assemble the components.
[131004870050] |The arithmetic part can be a little tricky because shells treat 0
as an octal prefix; for example here $(($5/15))
would fail at 8 or 9 minutes past the hour.
[131004870060] |Since there's at most one leading 0
, ${5#0}
is safe for arithmetic.
[131004870070] |Adding 100 and subsequently stripping the 1
is a way to get a fixed number of digits in the output.
[131004880010] |/usr/local
and the appropriate subdirectories (like bin
, lib
, share
, ...).
[131004890020] |Other software should be placed in their own directory under /opt
.
[131004890030] |Then either set your PATH
variable to include the bin
directory or whatever directory which holds the executables, or create symbolic links to /usr/local/bin
.
[131004900010] |There is no simple answer to this question, but I can give you a general outline of how it works:
[131004900020] |Most Linux software is provided by the authors (the "upstream") in source code form.
[131004900030] |This allows everyone who has a compiler for their particular platform and system configuration to download the sourcecode and compile it themselves.
[131004900040] |Unfortunately for you, many programs rely on functions provided by other programs and software libraries (dependencies).
[131004900050] |Windows software usually comes in precompiled form.
[131004900060] |That means there's one generic executable file for all Windows computers, and the dependencies often come with it in the install package.
[131004900070] |Linux distributions take the sourcecode, precompile it for you and offer it to you as a package, too.
[131004900080] |The package doesn't include the dependencies, but it refers to them and forces the package system to install them as well (which can sometimes lead to mess-ups which you've probably experienced yourself already).
[131004900090] |If there is no precompiled package, you can always download the source code and compile it yourself.
[131004900100] |Most of the time, the following will work:
[131004900110] |The ./configure line sets the stage for the compilation process (and spits out errors if dependencies aren't met).
[131004900120] |The make line will execute the Makefile, a script that compiles all parts of the program.
[131004900130] |Traditionally, you would use make install to then install the software.
[131004900140] |This usually puts the executables in /usr/local/bin.
[131004900150] |Since you're using apt, I very much recommend getting checkinstall.
[131004900160] |You can use it in place of make install, and it will generate a .deb package for you.
[131004900170] |This makes it much easier to cleanly remove the software later on.
[131004900180] |Note that there are a handful of other compilation sytems, for example cmake; and some software comes precompiled but unpackaged (in which case you can start it right from the unzipped folder); and some software comes as a collection of scripts you have to run yourself.
[131004900190] |Fresh code from SVN sometimes comes without configure scripts, so you have to first run the autoconf toolchain ... etc, etc ... you see there are lots of exceptions to the rule, but with a little experience you'll be able to tell what to do with most of those mysterious downloads.
[131004900200] |Configure-Make-Checkinstall is a good first start.
[131004900210] |PS.
[131004900220] |Spend a weekend or two to learn how to program yourself, and things will become very obvious :-)
[131004900230] |PPS.
[131004900240] |You may wonder why Linux software authors don't just provide precompiled packages instead of the sourcecode.
[131004900250] |Well, they sometimes do.
[131004900260] |But different platforms and Linux distributions all have their own package formats and file system rules, so as a developer you'd have to provide packages for every possible configuration -- which is a pain.
[131004900270] |Ubuntu packages are often the easiest to find though -- you should find out what a PPA is and how it works!
[131004910010] |There is a valid, sensible reason this is so confusing (there is also an annoying artifact reason)...
[131004910020] |Unix has a history of being multi-user and most users did not have access to install apps outside areas they had been granted specific access to.
[131004910030] |So the theory would be that you would build something in your home directory, then copy it to an area you had control over (your own project area, or a shared area).
[131004910040] |Windows PCs are generally single-user systems and don't have this constraint, everything goes in Program Files no matter what.
[131004910050] |Then there is the stupid, annoying fact that every time a new version of Unix came out the creators felt it necessary to change locations, but the old ones had to still be there for automated scripts.
[131004910060] |This gives you a bunch of linked directories serving the same purpose.
[131004910070] |The init system is even worse.
[131004920010] |You should check out checkinstall.
[131004920020] |Instead of
[131004920030] |you do
[131004920040] |and you'll be able to manage that package as if you had installed it through apt.
[131004930010] |Red Hat, Inc. is an
[131004940010] |A filesystem is a method of storing and organizing computer files and their data
[131004950010] |Compiling is the process of transforming source code into byte codes for a particular computer architecture
[131004960010] |RPM Package Manager is a package management system intended primarily for Linux distributions
[131004970010] |A free software re-implementation of the SMB/CIFS networking protocol, which provides Windows file and print services
[131004980010] |mutter --replace
each time I start Xorg (GNOME)?
[131004990010] |Press Alt + F2 and enter gconf-editor
.
[131004990020] |Navigate the tree menu to desktop >gnome >session >required-components.
[131004990030] |Now, replace the windowmanager
key with the window manager of your choice.
[131004990040] |Just replace gnome-wm (or metacity) with mutter.
[131004990050] |Another possible solution:
[131004990060] |You could add mutter --replace
to System >Preferences >Startup Applications which opens gnome-session-properties
program:
[131005000010] |Under Debian, if you want to change the window manager for all users, you can run (as root):
[131005000020] |and select the window manager you want as the default.
[131005000030] |However, this might only work if you're not using a desktop environment (e.g. GNOME or KDE).
[131005000040] |If you're using GNOME, you can tell it which window manager you want by putting the following in ~/.gnomerc
:
[131005010010] |~/local/bin/firefox/firefox
), I get the following error message:
[131005010040] |How can I run Firefox on Linux without requiring this shared object file?
[131005020010] |You can't; it is linked with the X and Gtk+ client libraries, and I don't think it's even possible to build it without them.
[131005030010] |You can't run Firefox without all the Gtk libraries it requires, but that's easily solved by installing the libraries.
[131005030020] |Normally you would install Firefox through a package management system and this would pull in all the required libraries.
[131005030030] |To run Firefox normally, you need an X server (that's the part that displays the windows and their contents, as opposed to things like Gtk which are libraries that the applicattion uses to build the content).
[131005030040] |That's something you wouldn't usually run on a server.
[131005030050] |There are a very few things you can do in Firefox without an X server, I don't know if Selenium is one of them.
[131005030060] |To run Firefox on your server, run a “virtual” X server.
[131005030070] |A simple one is Xvfb (virtual framebuffer X server).
[131005030080] |It's in the X.org server distribution.
[131005030090] |Sample usage:
[131005040010] |Since Selenium is a GUI testing tool, I would find it hard to believe that it can work without X.
[131005040020] |So my best guess is that your headless server requires an X installation such as that suggested by Gilles.
[131005040030] |There are a number of similar alternatives.
[131005050010] |/etc/fstab
or /boot/grub/menu.lst
files are valid while you are chrooted in your system (after mount /proc
above).
[131005060030] |There is also one more (shorter) way this can be done.
[131005060040] |Not sure if it is possible with the archlinux live cd, but probably is.
[131005070010] |/usr/share/doc/initscripts-*/sysvinitfiles
(On current F14, /usr/share/doc/initscripts-9.12.1/sysvinitfiles
).
[131005080020] |There's further documentation here: http://fedoraproject.org/wiki/Packaging/SysVInitScript.
[131005080030] |The chkconfig line defines which runlevels the service will start in by default (if any), and where in the startup process they'll be ordered.
[131005080040] |And, note that this all becomes obsolete with Fedora 15 and systemd
.
[131005090010] |The first line is the "she-bang" and is used to execute the script without having to pass it as an argument to a shell command line.
[131005090020] |The second line is a comment and is understood only by the chkconfig
program.
[131005090030] |It is used to ensure the script will start on a specific run-level.
[131005100010] |awk
prefixes each line with the line number followed by a space.
[131005110030] |The sort
reverses the order of the lines by sorting on the first field (line number) in reverse order, numeric style.
[131005110040] |And the sed
strips off the line numbers.
[131005110050] |The following example shows this in action:
[131005110060] |It outputs:
[131005120010] |Using sed
to emulate tac
:
[131005130010] |In perl:
[131005130020] |cat | perl -ne 'while(<>) { push @a, $_; } foreach (reverse(@a)) { print; }'
[131005140010] |awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' file.txt
[131005140020] |via awk one liners
[131005150010] |As you asked to do it in bash, here is a solution that doesn't make use of awk, sed or perl, just a bash function:
[131005150020] |The output of
[131005150030] |is
[131005150040] |As expected.
[131005160010] |iostat -d -p
, but that is limited to the whole partition.
[131005210010] |You can use inotifywait -m DIRNAME
from the inotify-tools.
[131005220010] |I don't think there's a direct way.
[131005220020] |One way to get the data you want would be to access the directory tree through a virtual filesystem that logs accesses.
[131005220030] |Loggedfs is one such filesystem, though I don't know if it can show all the data you're interested in.
[131005220040] |(If not it would probably be a modest coding effort to that data.)
[131005230010] |I realize this is going to sound both simplistic and absurd,but... if you have control over the apps in question (maybe in a test environment) you could mount ONLY that directory on a partition of its on, then. iostat, etc would tell you only about it, and nothing else on that spot.
[131005230020] |If there are physical drives involved you could fake it up with a loop back mount ala
[131005230030] |that would not completely remove all competing disk I/O, but I'm pretty sure iostat's output would be more specific to your need.
[131005240010] |/var/log/installer/syslog
for the definitive answer if it exists it is part of the log of the instillation.
[131005290050] |But beware this is not guaranteed. (see other answers/comments for some of the reasons it may not work.)
[131005300010] |In Fedora, anaconda installer stores the config details of your install in root's home folder, that can give you some idea.
[131005310010] |Check the date of the root filesystem with dumpe2fs.
[131005310020] |I can't really think of how that could be anything other than the date you're looking for:
[131005320010] |This will tell you when file system was created.
[131005330010] |ls -alct /root
-> root home directory is created at install time
[131005340010] |I look at the oldest file in /boot (top of "ls -ltr /boot".
[131005340020] |Often there is an original boot sector from the first install there.
[131005340030] |On my oldest system this gives the date of original installation, despite having replaced everything in the machine and copied the contents of the file system around a few times :)
[131005350010] |mplayer dvd://1 -dvd-device /path/to/copy_on_hdd/ -dumpaudio -dumpfile audio.ac3
[131005370010] |last
, we noticed some funny characters for the TTY field.
[131005370040] |What do these characters mean?
[131005370050] |Note that at this time, the sysadmin was battling with NTP.
[131005370060] |And according to man last
, I can specify the tty using -t tty
:
[131005380010] |From utmp(5)
:
[131005380020] |So the I and { are just there to indicate that the system time is being changed.
[131005390010] |--question
returns exit code 1 if the directory is not up to date, but that is not the issue - Other directories which are not up to date do not get listed like this in the output.
[131005390050] |The usual exit code of the command above is 1
(presumably because of --question
), but after the given message it returns 2
. Also, strangely, this command does not print anything on standard error:
[131005390060] |No amount of debugging seems to entice make
to explain what is wrong:
[131005390070] |Any ideas what this could be?