[131084460010] |a oddball issue about usbnet [131084460020] |I use the usbnet to transfer data between the PC(Host) and Board(Device) which is a usb OTG device. [131084460030] |The USB driver provided by SYNOPSIS and is used in many other device(seems without Bugs). [131084460040] |But usbnet can not work well on my board. [131084460050] |By the way,the USB port works well ,only usbnet can not work. [131084460060] |I am sure I did right configuration about the usbnet. [131084460070] |The Host can ping the device with correct feedback but if I ping the Host from the device, the whole usbnet subsystem seemed crashed,then the link looks like disconnected. [131084460080] |It cannot ping from either Host or Device. [131084460090] |It drives me crazy. [131084460100] |I can`t find particular introduction about the USBnet.If you have some,could you shared with me? [131084460110] |Thanks a lot! [131084470010] |Bash: Display exit status in prompt: [131084470020] |The following gives me the correct exitStatus but colour variables are not expanded: [131084470030] |However, the one below, gives me the colours but the exit status does not update: [131084470040] |What is the right way to do this? [131084470050] |How can I fix this so that the exitStatus and colours both work? [131084480010] |Here you go - This Works For Me (TM) in Ubuntu and a custom Linux build. [131084480020] |It might be overkill for your case; lines 40-48 and 96-106 should be the most relevant. [131084480030] |The reason for putting the exit code detection in $PS1 is that one host has a read-only $PROMPT_COMMAND set before .bashrc is read. [131084490010] |Try: [131084500010] |When you run PS1='${RED}\h $(get_path) ${exitStatus}${NONE} ', the PS1 variable is set to ${RED}\h $(get_path) ${exitStatus}${NONE}, where only \h is a prompt escape sequence. [131084500020] |After the prompt sequences are expanded (yielding ${RED}darkstar $(get_path) ${exitStatus}${NONE}), the shell performs the usual expansions such as variable expansions. [131084500030] |You get a displayed prompt that looks like \e[1;31mdarkstar PATH 0\e[m. [131084500040] |Nothing along the way expands the \e sequences to actual escape characters. [131084500050] |When you run PS1="${RED}\h $(get_path) ${exitStatus}${NONE} ", the PS1 variable is set to \e[1;31m\h PATH 0\e[m. [131084500060] |The variables RED, exitStatus and NONE are expanded at the time of the assignment. [131084500070] |Then the prompt contains three prompt escape sequences (\e, \h, and \e again). [131084500080] |There are no shell variables to expand at this stage. [131084500090] |In order to see colors, you need the color variables to contain actual escape characters. [131084500100] |You can do it this way: [131084500110] |$'…' expands backslash-octal sequences and some backslash-letter sequences such as \n, but not including \e. [131084500120] |I made three other changes to your prompt: [131084500130] |
  • Use \[…\] around non-printing sequences such as color-changing commands. [131084500140] |Otherwise your display will end up garbled because bash can't figure out the width of the prompt.
  • [131084500150] |
  • \w is a built-in escape sequence to print the current directory.
  • [131084500160] |
  • You don't need anything complicated to show $? in the prompt if you don't have a PROMPT_COMMAND in the first place.
  • [131084510010] |Gilles identified your main problem, but I wanted to try explaining it differently. [131084510020] |Bash is effectively calling echo on your PS1, not echo -e. [131084510030] |So it's like you're doing: [131084510040] |If you try running that, you will see it doesn't work. [131084510050] |But bash gives you a way to write special characters that doesn't require using echo -e. [131084510060] |It looks like $'\octal number'. [131084510070] |The special character in all the escape sequences is \e, which just means Escape. [131084510080] |Escape's octal value is \033. [131084510090] |So we want it to expand to this instead: [131084510100] |To do this, you can change your definition of GREEN, RED, and NONE, so their value is the actual escape sequence. [131084510110] |If you do that, your first PS1 with the single quotes should work: [131084510120] |However, then you will have a second problem. [131084510130] |Try running that, then press Up Arrow, then Home, and your cursor will not go back to the start of the line. [131084510140] |To fix that, change PS1 to include \[ and \] around the color escape sequences, e.g. [131084510150] |And it should all be working. [131084510160] |(I'm not sure why putting \[ around ${exitStatus} works, because the exit status number shouldn't have those around it, but it seems to work for me.) [131084520010] |How to time grep commands accurately? [131084520020] |I want to compare the speed of these two commands: [131084520030] |Unfortunately, the first grep reads much of files* into memory buffers, so the second grep runs very quickly, but for the wrong reason. [131084520040] |How do I tell Linux (Fedora 11): "please stop caching disk reads because I'm testing something." [131084530010] |I don't think you can, easily, tell it "temporarily stop caching". [131084530020] |But what you can do is tell the system to drop the cache before each run: [131084530030] |As root: [131084530040] |(This is documented in the kernel docs at Documentation/sysctl/vm.txt, which is handy if like some of us you can't always remember offhand what the values 1, 2, or 3 do.) [131084530050] |Or alternately, of course, prime the cache and compare the cached performance. [131084530060] |(I think both are useful numbers.) [131084540010] |When timing things like this I usually run it first to prime the cache. [131084540020] |Then run the command using time. [131084540030] |In testing something like this you should be more concerned about CPU and elapsed times, and less concerned about I/O time. [131084540040] |In any case it is difficult to get fully accurate timings. [131084540050] |If the input files exceed the size of memory available for buffers, then you will likely end up cycling all the files through buffer cache. [131084540060] |Otherwise, you may just access all the data from buffer cache. [131084540070] |In real life, there is often a mix of buffered data and data read from disk. [131084550010] |Kernel can't find /dev/sda file during boot [131084550020] |I configured a gentoo kernel (kernel-2.6.36-gentoo-r5), but when I boot it can't mount /dev/sda1: [131084550030] |I use the shell to go to the /dev directory, and I find that it have no sda* or hd* files. [131084550040] |However, when I boot into my Debian kernel (vmlinuz-2.6.32-5-686), it can find and mount the /dev/sda1 partition. [131084550050] |What's the problem? [131084550060] |How can I fix it? [131084550070] |I didn't add any module names to /etc/modules.autoload.d/kernel-2.6 file to let them auto-load during boot -- is that the cause of the problem? [131084560010] |You need to make sure that you select the correct SATA drivers while configuring your kernel. [131084560020] |I don't know what your hardware is, so you'll need to find out for yourself which drivers will work for you. [131084560030] |I always build the SATA drivers into the kernel rather than as a module, it's just easier to deal with. [131084570010] |For first-time Gentoo users, I strongly suggest using genkernel instead of plain make menuconfig. [131084570020] |By default, genkernel will include all drivers it thinks is required. [131084570030] |If you have the time, re-run genkernel and gradually reduce the drivers you don't need, edit grub.conf, and reboot. [131084570040] |Keep reducing. [131084570050] |Note the settings (get the .config file). [131084570060] |In my case, I chose to do a re-installation, this time use the .config file and go straight to make. [131084570070] |Not necessary, but I just dislike having many half-baked kernels lying around, plus some (possibly irrational) dislike of having to boot initrd. [131084570080] |(Well, at least that's how * I * did it. [131084570090] |Takes time, but ultimately satisfying :-) ) [131084580010] |dhclient exits with status 0 but still no address [131084580020] |I've been trying to find out with the man page and some other sources if the exit status doesn't necessarily mean you achieved an address but I'm thinking I maybe didn't read it correctly. [131084580030] |Does anyone know why dhclient would still exit with status 0 if it doesn't think I'm connected to a network? [131084580040] |RHEL 6 seems to have some serious network issues. [131084580050] |Mostly I'm just confused as to whether or not I'm reading what the exit status is supposed to mean here. [131084580060] |I run 'dhclient eth0' Nothing returns in stdout. [131084580070] |Yes where I am plugging in has DHCP set up correctly. [131084580080] |I should mention that if I pop in Fedora 13 live disc and drop to bash I can do the exact same steps and get on the network just fine. [131084580090] |The only difference being that I used Fedora 13 rather than RHEL 6 disc. [131084590010] |Even with NetworkManager running, you can to use dhclient. [131084590020] |Try killing dhclient and call it again: [131084590030] |If this doesn't help, you must see your network configuration, there are a lot of information about it in manpages (see 'man -k dhclient'). [131084590040] |Anyway, this may help too: http://serverfault.com/questions/231076/configuring-dhcp-on-rhel-6 [131084600010] |Advantages of using a RTOS such as QNX or VxWorks instead of Linux? [131084600020] |When developing a solution that requires a real-time operating system, what advantages would an operating system such an QNX or VxWorks have over Linux? [131084600030] |Or to put it another way, since these operating system are designed specifically for real-time, embedded use - as opposed to Linux which is a more general system that can be tailored to real-time use - when would you need to use one of these operating systems instead of Linux? [131084610010] |I've not done any real-time work at all so take this with a grain of salt... [131084610020] |I'm told there's two categories of "real-time": hard real-time and soft real-time. [131084610030] |"Soft real-time" informally means "get it done as fast as possible". [131084610040] |I think that Linux on a modern CPU is good for this sort of thing. [131084610050] |"Hard real-time" informally means "get it done within a required time window". [131084610060] |The window can be quite small, milliseconds or something. [131084610070] |Flight control systems for cruise missiles or satellite launch vehicles seem like the canonical example. [131084610080] |Industrial process control systems might also need this. [131084610090] |The Stuxnet worm appears to have interferred with systems that do this sort of controlling. [131084610100] |You'd use RTOS in the latter situation. [131084610110] |RTOS often guarantee delivering an interrupt in less than so many instructions or clock ticks or whatever. [131084610120] |Another consideration might be that an RTOS is designed, tested and/or "proved" to not consume stack space without bound. [131084610130] |It can live inside a certain minimum amount of memory, and things like an "OOM Killer" don't exist because they are provably never needed. [131084610140] |Some of the goofier features of early FORTRAN come from this type of requirement. [131084610150] |When you compiled a FORTRAN II program, you knew exactly how much stack and how much heap it needed, since you couldn't recurse, and you couldn't dynamically allocate anything. [131084610160] |Realistically, the second consideration (guaranteed max memory consumption) may be more important in some safety-critical applications than "guaranteed interrupt latency of 0.001 seconds". [131084610170] |I would also imagine that stripping the selection process of the fig-leaf of supporting verbiage, you'd find that engineers choose an RTOS because "the requirements say to". [131084620010] |Some embedded systems (a) need to meet difficult real-time requirements, and yet (b) have very limited hardware (which makes it even more difficult to meet those requirements). [131084620020] |If you can't change the hardware, then there are several situations where you are forced to rule out Linux and use something else instead: [131084620030] |
  • Perhaps the CPU doesn't even have a MMU, which makes it impossible to run Linux (except uClinux, and as far as I know uClinux is not real-time).
  • [131084620040] |
  • Perhaps the CPU is relatively slow, and the worst-case interrupt latency in Linux fails to meet some hard requirement, and some other RTOS tuned for extremely low worst-case interrupt latency can meet the requirement.
  • [131084620050] |
  • Perhaps the system has very little RAM. [131084620060] |A few years ago, a minimal Linux setup required around 2 MB of RAM; a minimal eCos setup (with a compatibility layer letting it run some applications originally designed to run on Linux) required around 20 kB of RAM.
  • [131084620070] |
  • Perhaps there is no port of Linux to your hardware, and there isn't enough time to port Linux before you need to launch (pun!) your system. [131084620080] |Many of the simpler RTOSes take much less time to port to new hardware than Linux.
  • [131084630010] |How to have tail -f show colored output [131084630020] |I'd like to be able to tail the output of a server log file that has messages like: [131084630030] |etc, and if it's SEVERE, show the line in red; if it's INFO, in green. [131084630040] |What kind of alias can I setup for a tail command that would help me do this? [131084640010] |Have you had a look at ccze? [131084640020] |You have the possibility to customize the default colors of some keywords using the option -c or directly in your configuration file. [131084640030] |Edit: [131084640040] |If you really would like to have the complete line colored in red, you could also have a try at the following: [131084640050] |\e[1;31m will give you the red color. [131084640060] |If you would like some yellow, use \e[1;33m. [131084650010] |Try out multitail. [131084650020] |This is an übergeneralization of tail -f. [131084650030] |You can watch multiple files in separate windows, highlight lines based on their content, and more. [131084650040] |The colors are configurable. [131084650050] |If the default color scheme doesn't work for you, write your own in the config file. [131084650060] |For example, call multitail -cS amir_log /path/to/log with the following ~/.multitailrc: [131084650070] |Another solution, if you're on a server where it's inconvenient to install non-standard tools, is to combine tail -f with sed or awk to add color selection control sequences. [131084650080] |This requires tail -f to flush its standard output without delay even when its standard output is a pipe, I don't know if all implementations do this. [131084650090] |Yet another possibility is to run tail -f in an Emacs shell buffer and use Emacs's syntax coloring abilities. [131084660010] |Try a little piece of software called 'ccze'. [131084660020] |tail -f somelogfile | ccze -A [131084670010] |You can use colorex, which allows to colorize lines based on regular expressions: [131084670020] |It also comes bundled with predefined configs, for example for Tomcat logs: [131084690010] |Also note that if you just want to look for one matching regex, GNU grep with --color will work — just pipe your tail output through that. [131084710010] |fsck - check and optionally repair a file system [131084720010] |emacs does not see my fonts in gentoo [131084720020] |Hi, [131084720030] |I copied my ~/.emacs file from ubuntu linux; I've installed Consolas font (and it works in gnome terminal, and as a default Monospace font); but Emacs does not see it [131084720040] |That's how I set the font in emacs, but it does not work (It worked and still works in Ubuntu) [131084720050] |What can I do? [131084720060] |Font select menu (menu-set-font, I guess) looks very strange, consists of three options: Misc, Courier and Fontset, and there are no sign of my system fonts [131084730010] |Support for TrueType fonts such as your Consolas font — more generally, support for client-rendered fonts — requires Emacs to be compiled against the Freetype and Fontconfig libraries. [131084730020] |This was introduced in Emacs 23. [131084730030] |Before, only traditional, server-rendered fonts were supported. [131084730040] |See the Emacs manual for more information about the two kinds of fonts and how to use them. [131084740010] |As Gilles said, to use a TrueType font like Consolas in Emacs 23 you must link it with the Freetype and Fontconfig libraries. [131084740020] |In Gentoo, you do that by turning on the xft use flag when building Emacs. [131084740030] |You'll need to turn that flag on (either globally or just for app-editors/emacs) and reinstall Emacs. [131084750010] |Converting html table into ncurses-like ascii table? [131084750020] |I have some documentation in an html table. [131084750030] |I want to convert the table to an ascii table, like you see when you get a mysql command line result back, like this: [131084750040] |... so I can include it in some code comments. [131084750050] |How could I do this easily? [131084750060] |I was thinking piping the output of lynx into a file, but lynx doesn't put ascii borders around tables :P [131084750070] |I also want to control cell width, so that the content cells don't spill outside the accepted screen width of the code. [131084760010] |You are better off using links for table rendering: [131084770010] |How to remove all empty directories in a subtree? [131084770020] |How can I remove all empty directories in a subtree? [131084770030] |I used something like [131084770040] |but I needs to be run multiple times in order to remove directories containing empty directories only. [131084770050] |Moreover, it's quite slow, especially under cygwin. [131084780010] |If you just tack a -p on your rmdir, that'll work in one pass. [131084780020] |It won't be pretty or optimal, but it should get everything. [131084780030] |That tells rmdir to remove any non-empty parent directories of the one you're removing. [131084780040] |You can save a little bit by adding the -empty test to find, so it doesn't bother with non-empty directories. [131084790010] |List the directories deeply-nested-first. [131084790020] |This won't help with the speed. [131084790030] |Try one of [131084790040] |Both are likely to be noticeably faster than the original, especially under Cygwin. [131084790050] |I don't expect much difference between these two. [131084800010] |svn command to see a tally of my changes [131084800020] |Is there an SVN command that I can run to see a tally of all of my contributions? [131084800030] |Something like: [131084810010] |I don't know about a single SVN command, but this seems to work: [131084810020] |Use your username instead of "username". [131084820010] |GNU Screen makes Vim ESC key slow [131084820020] |Screen makes my ESC key wait for more commands I beleive, and if it does not get those commands, it sends it to my terminal Session (which I am running VIM in). ESC is used alot in VIM and currently I do not make any use of the ESC key in Screen. [131084820030] |How would I go about changing the timeout? [131084820040] |I have read that these commands below inside of .screenrc should fix it, but it doesn't seem to be working for me: [131084830010] |I would change the screen key binding away from esc to something like ctrl. [131084830020] |I have not experienced anything like what you are describing with the default binding in .screenrc in AIX, Fedora, Debian, or Ubuntu. [131084840010] |Can I make scripts use aliases instead of commands? [131084840020] |I have an alias for a command (I'm setting up a Python development environment) [131084840030] |so that I can run ~/virtualenv/bin/python by just typing python. [131084840040] |Now in my project there is a shell script that goes, for example: [131084840050] |Can I make the script use my aliased python instead of the python it finds in $PATH, without making changes to the script? [131084850010] |Yes. [131084850020] |If you put your aliases in ~/.aliases, then you can do [131084850030] |This assumes your script starts with #!/bin/bash, because #!/bin/sh is a little less predictable. [131084850040] |Here's what I'd suggest: [131084850050] |
  • Create ~/.bashenv
  • [131084850060] |
  • Move all the settings that you want to work in scripts from ~/.bashrc into ~/.bashenv
  • [131084850070] |
  • Add this at the top of your ~/.bashrc: [ -f ~/.bashenv ] &&source ~/.bashenv
  • [131084850080] |
  • Put BASH_ENV=~/.bashenv in /etc/environment
  • [131084850090] |
  • Make your scripts start with #!/bin/bash if they don't already
  • [131084850100] |Or, if you're using zsh, just move your aliases into ~/.zshenv. zsh looks in that file automatically. [131084850110] |But maybe it's easier to just put ~/virtualenv/bin near the front of your PATH, then change your Python scripts to have #!/usr/bin/env python as the first line. [131084860010] |Supposing that your alias file is "~/.bash_aliases", put this in your script: [131084860020] |(via) [131084870010] |Is it possible in bash, to start reading a file from an arbitary byte count offset? [131084870020] |I want to locate a date which is somewhere in an 8 GB log (text). [131084870030] |Can I somewhat bypass a full sequential read, and first do binary splits of the file (size), or somehow navigating the filesystem inodes (which I know very little about), to start reading from each split point, until I find a suitable offset from where to start my text search for a line cotaining the date? [131084870040] |tail's read of the last line doesn't use a normal sequential read, so I wonder if this facility is somehow available in bash, or would I need to use Python or C/C++... but I am specifically interested in a bash option.. [131084880010] |I'd try something like this to split the log into 512MiB chunks for quicker parsing. [131084880020] |If you are looking for the file the following would work: [131084880030] |Use that output to determine which file to grep for your date. [131084890010] |which .. creates no temp-split files, skips blocks * 512MB of data at each run, reads 64 bytes from that position and limits the output to the first line of that 64 bytes. [131084890020] |you might want to adjust 64 to whatever you think you need. [131084900010] |It sounds like you want: [131084900020] |or whatever number of bytes you want to skip. [131084900030] |The plus sign tells tail to measure from the start of the file instead of the end. [131084900040] |If you're using the GNU version of tail you can write that as: [131084900050] |To get a fixed number of bytes after the cut, instead of all the rest of the file, just pipe it through head: [131084910010] |How do you rename root? [131084910020] |Not that its a very good idea to change it, but for fun. [131084910030] |According to this post, there are still some problems even after changing entries in etc/passwd and etc/shadow(and sudoers). [131084910040] |Any suggestions? [131084920010] |Theoretically, changing it in /etc/passwd and /etc/shadow would be all you need to 'rename' root. [131084920020] |The problem occurs because pretty much every single piece of unix software in existence assumes that the username 'root' exists and that it is the superuser -- mail aliases, various daemons, cron... [131084920030] |If you're really hell bent on trying it, find /etc -type f -exec grep -l root {} should be a good start at finding a list of every config file you'll probably need to change - but like you already said, this is a really bad idea in almost every conceivable situation. [131084930010] |suggestion: do not do that. [131084930020] |some tools try to talk to root via uid, there you should not have problems. some tools assume your root account is called root, and will break. unless you are prepared to, like, recompile half your system "for fun", just dont try. [131084940010] |squid (reverse proxy) configuration [131084940020] |Hello, [131084940030] |I would like to configure squid in such way, so that only specific (public) ip (reverse proxy), could connect to the server, but I don't know how... can someone tell me how to do this? [131084950010] |Just read the squid.conf file. [131084950020] |The default installation on Ubuntu only works for localhost. [131084950030] |You will need to set up an ACL to enable access. [131084950040] |This can include any address or address you choose. [131084950050] |You may want to review instructions for Setting up a Squid Proxy on Ubuntu. [131084950060] |They should be applicable to most platforms. [131084960010] |In Squid this is done by specifying the public IP address in http_port, and using loopback address for the web server and Apache may be configured like in httpd.conf to listen on the loopback address: [131084960020] |Port 80 BindAddress 127.0.0.1 [131084970010] |How to send mail ? [131084970020] |Hi, I'm trying to send mail from shell(GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)) using; [131084970030] |After I complete the command, the mail won't show up in the mailbox. [131084970040] |What could be wrong, how can I check is my configuration is correct. [131084970050] |Thanks. [131084980010] |Like every unix program that occasionally has cause to send email notifications, mail assumes that there is a functioning MTA on localhost that is 1) capable of accepting mail and 2) knows how to pass it on. [131084980020] |To find out what mail server you're running, try telnet localhost 25 and look at the identifier string. [131084980030] |The command mailq, if it exists for you, will show you what messages are currently in the local mail server's queue, possibly with an explanation as to why it hasn't been passed on to its destination yet. [131084980040] |In addition, most distributions by default configure MTAs and syslog to report mail log messages to either /var/log/mail.log or similar. [131084980050] |Look in /var/log/ for any file that looks viable, and grep it for 'bar.com' [131084980060] |Without more information as to what's going on it's hard to offer better advice than this, sorry. [131084990010] |Use a "mail" command that has an option to show you the SMTP dialog. [131084990020] |The "heirloom" project has a good version of such a command: http://heirloom.sourceforge.net/mailx.html [131084990030] |Here's an example "mailx" (apparently a 4-year-old v12.1) command invocation, showing the SMTP dialog: [131084990040] |That sort of information can be invaluable in figuring out what goes wrong with email delivery. [131085000010] |Reading an Microsoft Excel File [131085000020] |How to read an XLS File (Microsoft Excel) using unix Bash / Corn shell script? [131085010010] |With straight-up shell script you're more than likely sunk, but there are at least three Perl modules that can be used to parse excel spreadsheets and extract data from them. [131085010020] |Fair warning, none of them are particularly pretty, although Spreadsheet::ParseExcel::Simple is probably your best bet for a quick solution. [131085010030] |It's in debian 5.0 (Lenny) as libspreadsheet-parseexcel-simple-perl; Other distributions may have their own naming schemes. [131085010040] |Depending on what you want to do with it a quick perl script should do the trick. [131085020010] |It is hard to work with closed format like the old Office formats, convert it into a xml based format using Office/OpenOffice/LibreOffice. [131085020020] |Then use xsltproc (or some other xml parser) to get the data in a way that you can work with. [131085030010] |Fixing debian installer [131085030020] |I have a VPS with Debian GNU/Linux on it. [131085030030] |I'm trying to install a PHP file manager so that people could access it and download stuff into a directory. [131085030040] |I don't have anything in my /bin about PHP so this is probably an issue. [131085030050] |I installed PHP with this command: [131085030060] |and it says [131085030070] |It's saying php is already installed? [131085030080] |I try to confirm this by typing php -v and it says [131085030090] |Why is this and how can I get php running? [131085040010] |What version of Debian is that? [131085040020] |You might run updatedb and then locate php | grep bin, this should check if there's anything PHP-y installed. [131085040030] |Also, check if your executable isn't php-cgi or php5-cgi (you need an extra package for the CLI: php5-cli). [131085040040] |In any event, tell us your Debian version. [131085050010] |Moving that comment to its own answer, looks like your /etc/apt/sources.list is faulty. [131085050020] |Edit it to remove the line that contains debian-security, and replace it with [131085050030] |deb http://ftp.nl.debian.org/debian/ lenny main contrib non-free [131085050040] |for the main distribution, [131085050050] |deb http://security.debian.org/ lenny/updates main contrib non-free [131085050060] |for security updates, and [131085050070] |deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib non-free [131085050080] |For so-called 'volatile' updates, then run apt-get update; apt-get -uf upgrade to bring your entire system up to date, and then try installing php5-cgi again. [131085050090] |(ETA: You can replace 'nl' with your own country code to get servers a little closer to your physical location and hopefully better download speeds) [131085060010] |Linux adoption path for a .NET developer [131085060020] |I am a .NET C# programmer, I love the .NET stack. [131085060030] |I have tried Linux several times but every time I got put off as I could not do anything on it .. (like program for it or on it). [131085060040] |Ever since Mono was launched, I find myself using Linux a lot more. [131085060050] |(I have also decided to start learning Python.) [131085060060] |I would love to learn more about the OS itself - the shell commands, the underlying APIs etc [131085060070] |Where do I start, are there any books that are recommended for this? [131085060080] |I bought a copy of the - Unix Tools 3rd Edition O'Reilly and plan to go over it (end to end) are there any other recommended books? [131085060090] |Note: Not that this would matter, but I am using Ubuntu 10.04, I would like to have Fedora, but I have seen many users post issues with their Mono installations on it. [131085070010] |I posted some suggestions for books here: [131085070020] |http://unix.stackexchange.com/questions/80/recommended-readings-for-better-understating-of-unix-linux-internals/214#214 [131085070030] |As for developing on Linux with .NET, I strongly recommend that you install the MonoDevelop IDE (http://www.monodevelop.com). [131085080010] |If you want to develop for Linux, you might want to learn first about the different choices you have. [131085080020] |But if you're going the Python way, then things may be simpler. [131085080030] |I really like the Python + GTK + GNOME stack. [131085080040] |There are incredible tools which make development very easy. [131085080050] |Since you're a .Net developer, you might feel more comfortable with Java and forget pretty much about the underlying technologies: do I use Qt or GTK? [131085080060] |Mono will make you feel like at home, but know that not many like to have Mono on their computers. [131085080070] |There are good discussions about this on the Internet (i.e. gnote vs tomboy) [131085090010] |Mandatory The Art Of Unix Programming link here. [131085100010] |I found that the Advanced Scripting Guide was an excellent resource for shell scripting. [131085100020] |Reading through it and trying all the examples got me from someone who could just about navigate around the directory tree to someone who has a pretty good grasp of home to use the shell to do pretty much anything. [131085110010] |Remove alias from current session [131085110020] |How to remove a alias from current session without closing that session? [131085120010] |Supposing that your alias to python is py, do: [131085120020] |(via) [131085130010] |Can't connect to internet in Ubuntu 10.10 [131085130020] |I'm having trouble getting Ubuntu connected to the internet in vmware fusion. [131085130030] |Every other Linux distro has no trouble... [131085130040] |Ifconfig shows that eth0 is up and running, has been assigned an ipv4 address (DHCP) as well as an ipv6 address. [131085130050] |I can ping localhost, but nothing else. [131085130060] |It just stalls out. [131085130070] |I'm running vmware in NAT (as opposed to bridged) mode, which has worked fine for all other distros I've tried (Debian, BackTrack, openSuse...). [131085130080] |I thought Ubuntu was supposed to be ridiculously easy to work with? [131085130090] |Seems a lot of people have had this problem, but no clear answers yet. [131085130100] |Thanks in advance for any guidance! [131085140010] |We'll, my previous assumptions were wrong. [131085140020] |I've always read that you should run Linux under NAT in vmware, but I switched to bridged mode and now everything works. [131085140030] |My ip address in the virtual machine is now the same as my ip address on the main machine. [131085140040] |Hope this little tidbit of info helps someone... [131085150010] |russian letters in gentoo console as '?' [131085150020] |Hello, [131085150030] |I managed to get russian language working in my Gnome apps, but neither in the console (Alt-Shift-F2 and such) nor in the Gnome Terminal [131085160010] |Here are some of my suggestions: [131085160020] |
  • Have you enabled the unicode useflag? [131085160030] |Without it zsh won't be compiled with Unicode support. [131085160040] |If you're using bash, it should have Unicode support through libreadline. [131085160050] |Also, ksh and tcsh don't support Unicode at all.
  • [131085160060] |
  • It could also be your locale or font selections, but they look fine from what I can gather. [131085160070] |Just make sure to list your locale in /etc/locale.gen and generate it with locale-gen on the command line.
  • [131085160080] |Also, take a look at the Using UTF-8 with Gentoo guide from the Gentoo documentation. [131085170010] |closing a terminal without killing its children [131085170020] |Hello, [131085170030] |sometimes I run an app in the gnome-terminal, but then I suddenly have to restart gnome or something. [131085170040] |I guess the answer to the question is also useful then I want to disconnect from SSH where something is happenning. [131085170050] |Gnome's terminal tree looks like this: [131085170060] |Can I 'detach' bash from gnome-terminal (or detach some-boring-process from bash and redirect its output somewhere)? [131085170070] |If I just kill gnome-terminal, bash will be killed to will all its subprocesses [131085180010] |This is exactly what screen and tmux were created for. [131085180020] |You run the shell inside the screen/tmux session, and you can disconnect/reconnect at will. [131085180030] |You can also have multiple shell sessions running inside one gnome-terminal. [131085190010] |screen, tmux, or dtach (possibly with dvtm) are all great for this, but if it's something where you didn't think to use one of those, you may be able to leverage nohup. [131085200010] |If I fire something up which I want to finish no matter what (short of system reboot), I use nohup and run it in the background. [131085200020] |Unlike screen and the like you can't reattach to the processs. [131085200030] |However, baring redirection elsewhere any output can be found in nohup.out. [131085200040] |I do use screen when I want to be able to switch terminals for a process. [131085200050] |Such as starting a process from home/work and switching to the other. [131085200060] |Like any other terminal session output will eventual scroll off the top of the buffer. [131085210010] |If some-boring-process is running in your current bash session: [131085210020] |
  • halt it with ctrl-z to give you the bash prompt
  • [131085210030] |
  • put it in the background with bg
  • [131085210040] |
  • note the job number, or use the jobs command
  • [131085210050] |
  • detach the process from this bash session with disown -h %1 (substitute the actual job number there).
  • [131085210060] |That doesn't do anything to redirect the output -- you have to think of that when you launch your boring process. [131085210070] |[Edit] There seems to be a way to redirect it https://gist.github.com/782263 [131085210080] |But seriously, look into screen. [131085210090] |I have shells on a remote server that have been running for months. [131085220010] |If you want to keep interacting with the child process rather than just backgrounding it and having it keep going, there's actually a program called retty which is a proof-of-concept for "stealing" a process from its current tty and reattaching it to the current one. [131085220020] |It, however, does some horrible things, including sticking some assembly code on to the stack of the re-attached application. [131085220030] |And that code hasn't been updated for x86_64. [131085220040] |There's another program which takes a maybe-better approach, freezing the process in user-space to a file, from which it can later be restored (possibly on another tty.) This is cryopid, and that project too seems to have stopped in the proof-of-concept phase, and doesn't work with modern Linux as the code stands. [131085220050] |Ah well. [131085220060] |Just thought this should be here for completeness. [131085220070] |If you don't mind resorting to horrible voodoo, this is within the realm of possibility -- at least, theoretical possibility. [131085230010] |mv failed halfway through - is source directory intact [131085230020] |I ran mv a-folder /home/me on a machine and half way through the move the destination device filled up. [131085230030] |a-folder was made up of folders and files in various subdirectories. [131085230040] |Does mv leave the source folder intact until the move has successfully completed? [131085230050] |The source and destination folders were on different filesystems. [131085230060] |The reason I ask is that I ran this command on the wrong machine, so if the source folder is intact then that makes my life a lot easier :) [131085240010] |No your source folder is not intact... [131085240020] |On the same file system all mv does is add and remove directory entries. [131085240030] |But on a different filesystem... [131085240040] |I'm not sure at what point it unlinks the file, and whether it removes data as it goes... but once a file is moved, it is unlinked. [131085240050] |This is unless of course you used a special option to mv. [131085240060] |Some of which are mentioned in this question which might interest you in the future. [131085250010] |xenoterracide's answer is 100% correct, I'll just add to it. [131085250020] |I often monitor the copy or move process of large amounts of files with: [131085250030] |This will show you how the cumulated file size changes over time, proving to you that files are moved and removed (with mv) progressively along the way. [131085260010] |Is there an analog of apt-pinning in Fedora? [131085260020] |Apt pinning is a feature that allows to set install priority for a group of packages, determined by a number of attributes, such as package version, repository, distro version, etc. [131085260030] |See man apt_preferences for more (http://linux.die.net/man/5/apt_preferences) [131085260040] |Quote: [131085260050] |APT then applies the following rules, listed in order of precedence, to determine which version of a package to install. [131085260060] |
  • Never downgrade unless the priority of an available version exceeds 1000. [131085260070] |("Downgrading" is installing a less recent version of a package in place of a more recent version. [131085260080] |Note that none of APT's default priorities exceeds 1000; such high priorities can only be set in the preferences file. [131085260090] |Note also that downgrading a package can be risky.)
  • [131085260100] |
  • Install the highest priority version.
  • [131085260110] |
  • If two or more versions have the same priority, install the most recent one (that is, the one with the higher version number).
  • [131085260120] |
  • If two or more versions have the same priority and version number but either the packages differ in some of their metadata or the --reinstall option is given, install the uninstalled one.
  • [131085260130] |Is there anything like that for Fedora? [131085260140] |In other rpm-based distros? [131085270010] |Apt is available for Fedora, and is just a port of the Debian one afaik. [131085270020] |So you could use pinning with that. [131085280010] |Yum has a plugin architecture, and there are several plugins which implement some of what you're looking for. [131085280020] |The rules aren't exactly the same, but you may be able to get a behavior which matches your needs. [131085280030] |
  • yum-plugin-protectbase: This plugin allows certain repositories to be protected. [131085280040] |Packages in the protected repositories can't be overridden by packages in non-protected repositories even if the non-protected repo has a later version.
  • [131085280050] |
  • yum-plugin-versionlock: This plugin takes a set of name/versions for packages and excludes all other versions of those packages (including optionally following obsoletes). [131085280060] |This allows you to protect packages from being updated by newer versions, for example.
  • [131085280070] |And, not strictly related but maybe useful: [131085280080] |
  • yum-plugin-protect-packages: this plugin prevents Yum from removing itself and other protected packages. [131085280090] |By default, yum is the only package protected, but by extension this automatically protects everything on which yum depends (rpm, python, glibc, and so on). [131085280100] |Therefore, the plugin functions well even without compiling careful lists of all important packages. [131085280110] |(This latest is built-in to recent yum.)
  • [131085280120] |There's some documentation of the versionlock plugin in the yum faq. [131085280130] |All of these are in individual sub-packages, so you can just yum install yum-plugin-versionlock, and then check the configuration, usually under /etc/yum/pluginconf.d/. [131085280140] |(There's also decent man pages for yum-versionlock and for yum-versionlock.conf.) [131085290010] |Alias in cygwin bash doesn't seem to run in the right order. [131085290020] |I am trying to create an alias to use in my Cygwin shell to determine if the Mercurial-managed directory I'm currently in has outstanding changes. [131085290030] |The command "hg st -m" lists all modified files. [131085290040] |Unfortunately it doesn't set an exit value based on whether there are changes or not. [131085290050] |So I have tried capturing the output and seeing if it's not empty, piping it through "wc -l" and checking if that's -gt 0, but I seem to have a larger problem in that lines are clearly not executing in the order I would expect them to. [131085290060] |Here is what I've boiled it down to: [131085290070] |I put in the "Ln" echo statements for debugging. [131085290080] |When I run it by typing in "hgfoo" in a directory that has changes, I see the following output: [131085290090] |When I run it in a directory without changes, I see: [131085290100] |Even forgetting about the fact that the comparison is not working right, in both cases it seems to be running lines multiple times and in the wrong place. [131085290110] |This is driving me crazy. [131085290120] |Any clues? [131085290130] |Thanks. [131085300010] |I got it to work. [131085300020] |It was indeed the backticks causing the problems. [131085300030] |I refactored it as [131085300040] |then checked the exit value of grep, which is working perfectly. [131085310010] |This is a long-standing bug in bash's alias expansion. [131085310020] |I could reproduce it on Debian lenny amd64 with bash 3.2.29(1), Debian squeeze i386 with 4.1.5(1), and Windows XP with Cygwin 1.7.7-1 with bash 4.1.9(3). [131085310030] |A few experiments show that the bug is very sensitive to variations in how the alias is used. hgfoo or hgfoo : exhibits the bug, but { hgfoo :; } and (hgfoo) work fine. [131085310040] |Using a function instead of an alias also works. [131085310050] |I investigated a bit, trying to extract a smaller example. [131085310060] |The weirdness seems to stem from having a newline in the alias. [131085310070] |Here is a simple example where bash (3.2.29 or 4.1.9) misbehaves. [131085310080] |This alias works as expected (from my reading of Single Unix v3) under pdksh, ksh93, ash and zsh under Debian lenny, namely oops prints foo bar. [131085310090] |The bug may be related to a reported bug about “strange delayed aliases”, but that discussion focuses on line continuations (backslash-newline) which is not used here. [131085310100] |In any case, use a function! [131085310110] |Aliases are for one-liners where you're just specifying some default options for a command. [131085310120] |A function would have the additional benefit that you could pass arguments to hg: [131085310130] |¹ I initially thought this was a Cygwin bug, but as ak2 pointed out, this bug occurs under Linux as well. [131085320010] |How to get a notification when my commands are done [131085320020] |I'm running a series of commands on the command line that takes approximately twenty minutes to complete. [131085320030] |I'd like to see some sort of notification on my Mac when these are finished so I don't need to monitor the terminal for when it finishes. [131085320040] |Is there a way to do this? [131085320050] |Edit: [131085320060] |I could use xclock but this seems like a hack. [131085320070] |Ideally I could send the notification anywhere, like my phone, screen, etc. [131085330010] |How to cache or otherwise speed up `du` summaries? [131085330020] |We have a large file system on which a full du (disk usage) summary takes over two minutes. [131085330030] |I'd like to find a way to speed up a disk usage summary for arbitrary directories on that file system. [131085330040] |For small branches I've noticed that du results seem to be cached somehow, as repeat requests are much faster, but on large branches the speed up become negligible. [131085330050] |Is there a simple way of speeding up du, or more aggressively caching results for branches that haven't been modified since the previous search? [131085330060] |Or is there an alternative command that can deliver disk usage summaries faster? [131085340010] |What you are seeing when you rerun a du command is the effect of disk buffering. [131085340020] |Once you read a block its disk buffer is kept in the buffer cache until that block is needed. [131085340030] |For du you need to read the directory and the inode for each file in the directory. [131085340040] |The du results are not cached in this case, but can be derived with far less disk IO. [131085340050] |While it would be possible to force the system to cache this information, overall performance would suffer as the required buffer space would not be available for actively accessed files. [131085340060] |The directory itself has no idea how large a file is, so each file needs to be accessed. [131085340070] |To keep the cached value up to date every time a file changed size the cached value would need to be updated. [131085340080] |As a file can be listed in 0 or more directories this would require each file's inode to know which directories it is listed in. [131085340090] |This would greatly complicate the inode structure and reduce IO performance. [131085340100] |Also as du allows you to get results assuming different block sizes, the data required in the cache would need to increment or decrement the cached value for each possible block size further slowing performance. [131085350010] |If you can arrange for the different hierarchies of files to belong to different groups, you can set up disk quotas. [131085350020] |Don't give an upper limit (or make it the size of the disk) unless you want one. [131085350030] |You'll still be able to tell instantly how much of its (effectively infinite) quota the group is using. [131085350040] |This does require that your filesystem supports per-group quotas. [131085350050] |Linux's Ext[234] and Solaris/*BSD/Linux's zfs do. [131085350060] |It would be nice for your use case if group quotas took ACLs into account, but I don't think they do. [131085360010] |backup MSSQL server using a mysqldump-like tool [131085360020] |I'm trying to backup a MSSQL server from linux. [131085360030] |I'm able to connect to the server using tsql (from the freetds project), and I'm even able to backup the database on the server using the backup database command, but I haven't been able to download this backup onto the machine I'm using to connect to the MSSQL server. [131085360040] |If this was a mySQL server, I could download a backup of the database using mysqldump. [131085360050] |Is there something similar I can do for an MSSQL server in linux? [131085370010] |I can't remove a directory tree with rm -rf [131085370020] |This seems very strange to me. [131085370030] |I'm running kernel 2.6.37.2 and ran: [131085370040] |I get some permission denies when copying as expected and I eventually hit Control-C. [131085370050] |I get Permission denied on a lot of files when trying to remove the new directory and files. [131085370060] |As a note, I found this weird behavior because a friend sent me a .tgz of a snapshot of his /proc dir. [131085370070] |I extracted the directory and when I was finished looking through it I had the same problem. [131085370080] |rm -rf as root does work. [131085370090] |lsattr shows the e attribute (which is what all of my files/directories show). [131085370100] |EDIT: Oh wow, I can't believe I didn't notice. [131085370110] |The directories had no write permission on them o.o [131085380010] |If there is a non-empty directory where you don't have write permission, you can't remove its contents. [131085380020] |The reason is that rm is bound by permissions like any other command, and permission to remove bar requires write permission on foo. [131085380030] |This doesn't apply when you run rm as root because root always has the permission to remove a file. [131085380040] |To make the directory tree deletable, make all the directories in it writable (the permissions of regular files don't matter when it comes to deletion with rm -f). [131085380050] |You can use either of these commands: [131085390010] |exim4 on debian: why does this ACL work when testing with -bh but not in actual use? [131085390020] |I've got local_acl_check_data to reject the typical spammer tactic of using the same address as From: and To:, but since some less-spammy sources, such as Yahoo Groups, do this, I'm using a whitelist as well. [131085390030] |Here is the ACL: [131085390040] |Problem is, when I test with: [131085390050] |It works as expected: the first message is accepted because it found yahoogroups.com in the whitelist, and the second was rejected. [131085390060] |But in real operation, the yahoogroups.com emails are rejected by that ACL along with the spammers. [131085390070] |I'm using 4.72-6, and this has happened for all the versions I've been using for the last few years. [131085390080] |I've run out of ideas. [131085390090] |As requested, the log of exim4 rejecting a message which should have passed: [131085390100] |And here's what my testacl script shows for the first test: [131085400010] |I have noticed this pattern, but don't think much is getting through. [131085400020] |Try this [131085400030] |I use control = freeze to hold messages for inspection when I am testing rules. [131085400040] |If I find it accurate enough I change it to a deny rule. [131085400050] |EDIT: I tested this rule in my database of emails. [131085400060] |Using zen.spamhaus.org as a DNS blacklist catches almost all these cases (467 of 483). [131085400070] |Greylisting catches most of the rest (11 of 16). [131085400080] |I found five message made it past those to tests. [131085400090] |Of those three (60%) were legitimate email. [131085400100] |The others had helo names which where either hostnames or second level domains. [131085400110] |Adding a condition to check to ensure the helo name is at least a third level domain makes the rule reasonably safe. [131085400120] |I am testing with: [131085410010] |The "sender", as Exim sees it is the envelope-from address, and that was in domain returns.groups.yahoo.com. [131085410020] |Once I put that domain (completely; groups.yahoo.com doesn't work, neither does yahoo.com) into my local_sender_whitelist, the ACL worked. [131085410030] |It had worked during testing because I had used the envelope-from address of yahoogroups.com, the same as the From: address. [131085410040] |Never bothered to check if that was the case in the emails from yahoo groups. [131085420010] |How do I determine the make & model of my storage devices? [131085420020] |Possible Duplicate: How do I find out what hard disks are in the system? [131085420030] |I'm running a CentOS 5.5 system. [131085420040] |This system has 4 disks and a 3ware RAID controller. [131085420050] |How can I determine the make and model of my drives? [131085420060] |/proc/scsi/scsi and parted --list shows the RAID controller (3ware 9650SE-4LP): [131085430010] |How is the octal 2-byte output calculated from od [131085430020] |Hi, [131085430030] |I'm struggling to work out what the octal 2-byte output from the od command is. [131085430040] |I understand the octal output (-b flag) but the octal 2-byte is a mystery to me (-o) [131085430050] |Can someone shed some light on how the -o result is calculated from ASCII? [131085430060] |Here is an example: [131085440010] |Interesting question. [131085440020] |After browsing the man page, I found that -o prints octal output (od == octal dump), the c you appended only prints the associated characters as well. [131085440030] |You get the same numbers with -o alone. [131085440040] |Looking at the output it appears that od is reading data two bytes at a time. [131085440050] |Take the first two characters for instance: [131085440060] |The answer comes when we concatenate the binary values (with the '1' on the right, the SPACE on the left): [131085440070] |Converting this binary value to octal gives us 020061, which is what od printed. [131085440080] |Now, why? [131085440090] |I think the point is that od is reading two bytes at a time, and it is not concerned or aware that those two bytes are actually two separate characters. [131085450010] |For hysterical historical reasons, od prints two-byte words¹ by default. [131085450020] |The number 020061 (octal) corresponds to the two-byte sequence 1␣ ( is a space character). [131085450030] |Why? [131085450040] |It's clearer if you use hexadecimal: 0o20061 = 0x2031, and is 0x20 (32) in ASCII and 1 is 0x31 (49). Notice that the lower-order bits (0x31) correspond to the first character and the higher-order bits correspond to the second character: od is assembling the words in little-endian order, because that happens to be your system's endianness.² [131085450050] |Little-endian order is not very natural here because one of the output formats (-c) prints characters, the other one (-o) prints words. [131085450060] |Each word is printed as a number in the usual big-endian notation (the most significant digit comes first in our left-to-right reading order). [131085450070] |This is even more apparent in hexadecimal where the byte boundaries are clearly apparent in the numerical output: [131085450080] |If you prefer to view the file as a sequence of bytes, use od -t x1 (or hd if you have it). [131085450090] |¹ Once upon a time, men were real men, computers were real computers, numbers were often written in octal, and words were two bytes long. [131085450100] |² All PCs (x86, x86-64) are little-endian, as was the PDP-11 where Unix started. [131085450110] |ARM CPUs can cope with either endianness but Linux and iOS use it in little-endian mode. [131085450120] |So most of the platforms you're likely to encounter nowadays are little-endian. [131085460010] |Is it possible to find the path of a running program? [131085460020] |I have a xmms2d process running, but two possible executable files (in different directories, both in the executable path) that could have spawned it. [131085460030] |I suspect that one of those is corrupted, because sometimes this program works and sometimes it doesn't. [131085460040] |The process running now works, so I want to delete (or rename) the other one. [131085460050] |ps ax|grep "xmms" returns 8505 ? SLl 2:38 xmms2d -v without path information. [131085460060] |Given the PID, could I find whether it was run from /usr/bin/xmms2d or /usr/local/bin/xmms2d? [131085460070] |Thanks! [131085470010] |Try this: [131085470020] |Or if you don't want to parse the output of ls, just do: [131085470030] |or [131085480010] |I start mousepad from the shell: [131085480020] |check, where it comes from: [131085480030] |start it with path: [131085480040] |look via ps: [131085480050] |As we see, the one invoked without path is displayed without path, and started with the PATH, and therefore to be found by [131085480060] |Simple as that, isn't it? [131085480070] |Wait! [131085480080] |What if I start mousepad from the menu? [131085480090] |Well, it might be specified with or without using the PATH settings. [131085480100] |I tried. [131085480110] |A normal start leads to a simple 'mousepad' in ps v -C. [131085480120] |Since ~/bin is the first part of my PATH I create a dummy there, and, voila, the dummy is started from the menu. [131085480130] |But what if you start a program which deletes itself? [131085480140] |Which will not find the deleted program and report a wrong one, if there is a second in the path. [131085480150] |So that's a race condition. [131085480160] |If you know that your programs don't delete themselves or aren't moved while you're investigating their location, ps v -C NAME and which NAME should work pretty well. [131085490010] |If you are running Solaris, the way is slightly different from the Linux one suggested: [131085490020] |Should you want to know the current working directory of running processes, you can use: [131085490030] |eg: [131085500010] |mdadm Raid5 gives spares missing events [131085500020] |Hi, [131085500030] |I succesfully builded up a raid5 array on debian testing (Wheezy). [131085500040] |As the manpages and further tell, the array would be created as an out of sync array with just a new spare injected to be repaired. [131085500050] |That worked fine. [131085500060] |But after the rebuild process, I get daily messages on missing spares - but the array should be raid5 over 3 discs without spare. [131085500070] |I think, I only need to tell mdadm, that there is and should be no spare - but how to? mdadm -Dgives [131085500080] |and /proc/mdstat reads [131085500090] |Any ideas? [131085500100] |Thanks in advance [131085510010] |Open the /etc/mdadm/mdadm.conf file, find the line that begins with ARRAY /dev/md1 and remove the line immediately following which states 'spares=1'. [131085510020] |Then restart mdadm service. [131085510030] |If you did a mdadm --examine --scan to retrieve the array definitions while the md1 array was still rebuilding, one partition was seen as spare at that moment. [131085520010] |Sharing Linux Printer to windows [131085520020] |Hello, I want to share the printer connected to Linux with Windows machine, so that windows-user can print to this Linux printer. [131085520030] |How can I do this ? [131085520040] |P.S. [131085520050] |I followed the http://tldp.org/HOWTO/SMB-HOWTO-9.html, but it did not worked. [131085520060] |I am using LFS-6.0 and windows machine is XP. [131085530010] |Although I share the printers using Samba, I access them directly using CUPS. [131085530020] |Windows works well with the IPP protocol. [131085530030] |For postscript output I am using the MS Publisher Imagesetter driver. [131085530040] |If you are having problems with printer sharing using Samba, it may be a browsing issue. [131085530050] |You need to be able to see your server first. [131085530060] |From my wireless network I can't browse the printers on my server, although I have access to a share from the server. [131085530070] |They do show up if I choose Select a shared printer by name. (\servername) brings up a drop-down list. [131085540010] |Converting text into ASCII/ISO-8859-1 [131085540020] |I'm looking for some tool that can convert text, ideally from UTF-8 (but ISO-8859-2 and WINDOWS-1250 would be fine) into ASCII/ISO-8859-1? [131085540030] |I have seen some online transliteration tools but I need something for the command line (and iconv is refusing to convert the file). [131085550010] |If you're ok to use Python, give a try to slugify which is made to do character conversion such as é => e. [131085550020] |And forget my previous answer mentioning konwert, which is used to format conversion. [131085560010] |By default, iconv refuses to convert the file if it contains characters that do not exist in the target character set. [131085560020] |Use //TRANSLIT to “downgrade” such characters. [131085570010] |How to get my own ip and attribute it to a variable in shell script? [131085570020] |How to get my own ip and attribute it to a variable in shell script? [131085580010] |It's not so easy if you want to take into account wlan and other alternative interfaces. [131085580020] |If you know which interface you want the address for (e.g., eth0, the first Ethernet card), you can use this: [131085580030] |In other words, get me the network configuration information, look for eth0, get that line and the next one (-A 1), get only the last line, get the second part of that line when splitting with :, then get the first part of that when splitting with space. [131085590010] |I believe the "modern tools" way to get your ipv4 address is to parse 'ip' rather than 'ifconfig', so it'd be something like: [131085590020] |or something like that. [131085600010] |I use this one-liner: [131085600020] |Uses ifconfig (widely available), does not take localhost address, does not bind you to a given interface name, does not take into account IPv6 and tries to get the IP of the first network interface available. [131085610010] |Killing gnome-panel often; how can I figure out why, or help someone else figure out why? [131085610020] |On my system (Debian Lenny AMD64), gnome-panel seems to act up now and again. [131085610030] |I've not found a way to force it to happen, but it seems related to launching processes. [131085610040] |Basically, I launch some process, and I see 1 core max itself out, and the taskbar freezes. [131085610050] |I pkill gnome-panel, the taskbar reappears, and everything is ok. [131085610060] |If I don't notice it, eventually my entire computer freezes and I have to hard boot. [131085610070] |If you're familiar with this, great; but if not, how would I go about getting some kind of information on why this is happening that could help me or developers? [131085610080] |Is there a debug build or something I could run? [131085610090] |Thank you. [131085620010] |You could try taking a look at the ~/.xsession-errors file. [131085620020] |If you're lucky you might find some failed assertion or error in there. [131085620030] |You could also install the gnome-panel-dbg package and attach gdb to the running panel to get a backtrace in case of crash (more information here). [131085630010] |How to get the network status (online/offline) and attribute it to a variable in shell script? [131085630020] |How to get the network status (online/offline) and attribute it to a variable in shell script? [131085640010] |If you use network manager for your network connection, you could query it via dbus somewhat like this: [131085640020] |(somewhat deprecated but still works, for newer interfaces you'd just query a different address) [131085640030] |If that returns a "3" you are "connected" as described in http://projects.gnome.org/NetworkManager/developers/spec.html#type-NM_STATE (but it says nothing about internet connectivity). [131085640040] |If you really wanna know whether you have internet connectivity, just ping a remote server like google.com and see if that worked or not. [131085650010] |I'm going to reccomend ip again: [131085650020] |(The ninth column is the state of the interface) [131085660010] |You say you simply want the online/offline status of an interface, and aren't concerned with speed or link-type. [131085660020] |Try ethtool, as root: [131085660030] |ifconfig can also show you the online/offline status, and this command is usually available to any user on the system. [131085670010] |another one... for older NICs, the command mii-tool is awesome [131085680010] |Using KDE in Debian Squeeze [131085680020] |I just installed Debian Squeeze and it defaulted to the gnome desktop environment. [131085680030] |I have installed KDE via the package manager but do not know how to set it as the default environment. [131085680040] |Any help would be appreciated. [131085690010] |You can choose what Desktop you want during log-in. [131085690020] |That is, instead of just entering your username and password, go to something named along the lines of Choose desktop session and select KDE. [131085690030] |From there, proceed to entering your username and password, and you should find yourself inside of a KDE desktop. [131085700010] |How do I prevent expansion when I use a pattern as argument to a script? [131085700020] |I need a very simple script which does this: [131085700030] |so that I can call it in this way: [131085700040] |the problem is that the shell expands the *.png pattern instead of passing it as it is to the script. [131085700050] |How can I achieve this (script, alias or any other equivalent solution is fine)? [131085710010] |Have you tried [131085710020] |But I can only see zsh (not bash) expanding it like you say. [131085720010] |Since the shell performs glob expansion before the arguments are handed over to the command, there's no way I can think of to do it transparently: it's either controlled by the user (quote the parameter) or brute-force (disable globbing completely for your shell with set -o noglob). [131085720020] |You're looking at the problem from the wrong end. [131085720030] |Change your script to accept multiple filename arguments: [131085730010] |Forcing sudo to prompt for a password [131085730020] |If I do the following: [131085730030] |The second invocation of sudo does not request a password because even though I have logged out again, I am still within some time limit meaning that I do not need to be prompted for my password again. [131085730040] |Because I am trying out some new privs to make sure they work, this is really slowing me down while I wait for the timeout to happen. [131085730050] |Is there a command I can run to reset the timeout? [131085730060] |I don't want to change the timeout or affect other users, by the way! [131085740010] |sudo -k Will kill the timeout timestamp. [131085740020] |You can even put the command afterwards, like sudo -k test_my_privileges.sh [131085740030] |From man sudo: [131085740040] |-K The -K (sure kill) option is like -k except that it removes the user's time stamp entirely and may not be used in conjunction with a command or other option. [131085740050] |This option does not require a password. [131085740060] |-k When used by itself, the -k (kill) option to sudo invalidates the user's time stamp by setting the time on it to the Epoch. [131085740070] |The next time sudo is run a password will be required. [131085740080] |This option does not require a password and was added to allow a user to revoke sudo permissions from a .logout file. [131085740090] |You can also change it permanently. [131085740100] |From man sudoers: [131085740110] |timestamp_timeout [131085740120] |Number of minutes that can elapse before sudo will ask for a passwd again. [131085740130] |The timeout may include a fractional component if minute granularity is insufficient, for example 2.5. [131085740140] |The default is 5. [131085740150] |Set this to 0 to always prompt for a password. [131085740160] |If set to a value less than 0 the user's timestamp will never expire. [131085740170] |This can be used to allow users to create or delete their own timestamps via sudo -v and sudo -k respectively. [131085750010] |Shawn's answer is great but there is an additional configuration option that might be useful in this situation. [131085750020] |From man sudoers: [131085750030] |tty_tickets [131085750040] |If set, users must authenticate on a per-tty basis. [131085750050] |With this flag enabled, sudo will use a file named for the tty the user is logged in on in the user's time stamp directory. [131085750060] |If disabled, the time stamp of the directory is used instead. [131085750070] |This flag is on by default. [131085750080] |From man sudo: [131085750090] |When the tty_tickets option is enabled in sudoers, the time stamp has per-tty granularity but still may outlive the user's session. [131085750100] |On Linux systems where the devpts filesystem is used, Solaris systems with the devices filesystem, as well as other systems that utilize a devfs filesystem that monotonically increase the inode number of devices as they are created (such as Mac OS X), sudo is able to determine when a tty-based time stamp file is stale and will ignore it. [131085750110] |Administrators should not rely on this feature as it is not universally available. [131085750120] |I think its relatively new. [131085750130] |If your system supports it, if you logout then login, sudo will request your password again. [131085750140] |(I have sudo -K in my shells logout script too.) [131085760010] |All my superblocks are corrupt! [131085760020] |I am having a problem with my ubuntu ext3 filesystem. [131085760030] |I can't boot from it or mount the volume when running live CD. [131085760040] |When I try e2fsck I get: "Bad magic number in super-block while trying to open /dev/sda5". [131085760050] |I have tried all the alternative superblocks with the same result. [131085760060] |I have heard you can delete the journaling system and mount as ext2, but the suggestions on how to do this (eg this one) all require a valid superblock. [131085760070] |Is it credible that all the backup superblocks are corrupted or is there something else going on? [131085760080] |The filesystem seemed fine before I rebooted, so pretty sure it's recoverable. [131085760090] |What else can I try? [131085760100] |

    Output from fdisk

    [131085760110] |

    Output from sudo file - `

    [131085760120] |(What was this supposed to show?) [131085760130] |

    Output from sudo file -s `/dev/sda5`

    [131085770010] |I'm afraid there isn't a recognizable filesystem on this partition any more. [131085770020] |It's time to restore from a backup. [131085770030] |Just in case there's a hardware problem such as bad RAM or a bad cable that's causing wrong data to be read, you can try reading from another machine. [131085770040] |But that's very unlikely to be the case if you can neither boot from the partition nor read it from a live CD environment. [131085770050] |One thing that's suspicious is that you have an extended partition starting at cylinder 8903, but the first logical partition on it starts at cylinder 8904. [131085770060] |Try sudo tail -c +513 /dev/sda2 | file - to see if there's something recognizable at the very beginning of the extended partition. [131085770070] |(I'm not sure the offset is always 512, it might be 4096 or 32256 or some other number; note that you need to add 1 to the offset for the tail command.) [131085770080] |If the problem is indeed that your partition table flipped a bit, use fdisk or your favorite partition editor to change /dev/sda5 back to starting at cylinder 8903. [131085780010] |How can I unmap Mod4+S and Mod4+M in Ubuntu [131085780020] |Mod4+S and Mod4+M (or Super+S and Super+M) are mapped to invoking the session management menu (on the rightmost of the GNOME panel), and to minimizing the current window. [131085780030] |How can I disable them? [131085780040] |They are not shown in System >Preferences >Keyboard Shortcuts. [131085790010] |Unable to handle kernel paging request? [131085790020] |[Disclaimer: I was initially a little nervous about posting this here, so I asked on Meta if discussing homebrew / modding was acceptable. [131085790030] |Based on the response I've gotten from several veteran members, I've gone ahead and posted this thread. [131085790040] |Here is the link on Meta.] [131085790050] |I'm currently trying to mod my original Xbox using xboxhdm and ndure 3.0. xboxhdm is built around a small bootable Linux distro, and it's giving me fits, so I figured that I'd ask here and see if anybody could give me a hand. [131085790060] |(Note: Before anybody suggests a different board, xboxhdm boots from CD on a PC - the Xbox hardware is completely uninvolved in the process, so that's why I'm asking here.) [131085790070] |The PC I'm using is relatively old - it's an old Compaq desktop with about 512mb RAM and a 2.5ghz processor (likely a P IV). [131085790080] |I'm using it because it has 2 IDE ports on the motherboard. [131085790090] |The age of the computer shouldn't be an issue, performance-wise - the xboxhdm + ndure hack has been around for years - it was designed to run on such hardware. [131085790100] |Anyway - at one point in the process, I have to copy some files from the CD to the Xbox hard drive (which is a standard Seagate IDE drive, powered by a Molex). [131085790110] |About halfway through the copy, everything just dies... [131085790120] |I get an unable to handle kernel paging request error, and eventually a kernel panic. [131085790130] |I couldn't find anything about this error and how it specifically relates to Xbox modding, but what information I could find suggested that I might have a bad stick of RAM. [131085790140] |I've not been able to test this yet, but I'm going to run MEMTEST as soon as I get home. [131085790150] |I don't have the setup with me - I'm at work, and it's at home - but if anybody's interested in lending a hand, I'll take pictures tonight and post them up. [131085790160] |The only reason that I'm asking here is because I'm still a fairly new *nix convert, and I'm not quite sure how it all works. [131085790170] |I'm assuming that unable to handle kernel paging request is a fairly standard error message, too... correct me if I'm wrong. [131085790180] |Anyhow, thanks in advance for any help. [131085800010] |Well. [131085800020] |How's that for fried RAM? [131085800030] |Guess that was the culprit, after all. [131085800040] |Thanks to everyone for their help and advice! [131085810010] |apache symlinks and dokuwiki [131085810020] |I am running a dokuwiki on an apache webserver. [131085810030] |Usually I put media files into the directory /var/lib/dokuwiki/data/media. [131085810040] |However, to be more flexible and to save disk space, it would be nice to use symbolic links instead of copying files to that directory. [131085810050] |Now my question is: [131085810060] |How to make apache to follow symlinks in the directory /var/lib/dokuwiki/data/media. [131085820010] |I believe FollowSymLinks is what you are looking for. [131085820020] |First you have to locate the Apache configuration files. [131085820030] |If you install Apache using your distro's package then they are more than likely to be in /etc/apache2/ and the file you have to change is httpd.conf. [131085820040] |If in your document root you have the symlink wiki/media -> /real/wiki/media then you will need to create a Directory section like this: [131085820050] |Please note that I am writing these from memory without any testing, so don't use these directions as is, consult the comments in the file, configuration guide for your distro and the Apache reference when in doubt. [131085830010] |Wireless in Debian Squeeze [131085830020] |I am trying to get wireless working a lenovo g560. [131085830030] |I tried following the instructions on the debian site here http://wiki.debian.org/wl but it is not working. [131085830040] |At step 7 I get an error that modprobe does not exist. [131085830050] |Anybody know of a straightforward tutorial or got any tips? [131085840010] |/sbin is not part of your PATH and thats why its complaining. [131085840020] |So try /sbin/modprobe. [131085850010] |rm -rf failing if deleting in parallel [131085850020] |rm -rf will fail if something tries to delete the same file tree (I think because rm enumerates the files first, then deletes). [131085850030] |A simple test: [131085850040] |There will be some output into stderr, e.g.: [131085850050] |I can ignore all the stderr output by redirecting it to /dev/null, but removing of /tmp/dirtest actually fails! [131085850060] |After both commands are finished, /tmp/dirtest is still there. [131085850070] |How can I make rm delete the directory tree properly and really ignore all the errors? [131085860010] |I'm curious how the build system ended up like this. [131085860020] |Are you able to change it? [131085860030] |At a minimum, you can create a flag that lets the scripts know the other one is already doing the job... [131085860040] |It would be better to re-architect the thing so that this isn't necessary. [131085870010] |Nasty. [131085870020] |But in a sense, you're looking for trouble when two concurrent processes are manipulating a directory tree. [131085870030] |Unix provides primitives for atomic manipulation of a single file, but not for whole directory trees. [131085870040] |A simple workaround would be for your script to rename the directory before removing it. [131085870050] |Since your use case has cooperating scripts, it's ok for the new name to be predictable. [131085870060] |Maybe you can even do the rm in the background later, while your build performs some CPU-bound tasks. [131085880010] |Parsing XML's , JSON's and newer data file formats in UNIX using command line utilities [131085880020] |Unix environment has some excellent tools for parsing text in various forms. [131085880030] |However off late the data is not in the regular set of formats(CSV,TSV,Record based or some other delimiter based) it used to be before. [131085880040] |Data these days is exchanged in structured formats like XML's/JSON's. [131085880050] |I know there are some good tools like sed, awk and Perl which can chew down nearly form of data out there. [131085880060] |However to work with this sort of structured data often one has to write a complete program and given the little time available to extract information, one has to sit down and figure out the whole logic of what one wants to query and put it down programatically. [131085880070] |Sometimes this is not OK. [131085880080] |Basically because the information extracted from those files acts inputs for further work. [131085880090] |Also because of the time it takes to search for the appropriate solution and coding it up. [131085880100] |A command line tool is needed with sufficient switches to find, query and dump data. [131085880110] |Im looking for tools that take a XML/JSON or other forms of structured data and dump it into other formats like csv etc. [131085880120] |So that from there one could use other commands to get any information out of it. [131085880130] |Are there any command line utilities you know of which do this kind of a job. [131085880140] |Are there already awk/Perl scripts available to this? [131085890010] |I guess Perl, Python or Ruby modules can be used successfully for that. [131085890020] |And any of these can be used for scripting. [131085900010] |for xml there is http://xmlstar.sourceforge.net/ [131085900020] |XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands. [131085900030] |you can also use xsltproc and similar tools (saxon). [131085900040] |for json: i also think its better to just use python, ruby, perl and transform it. [131085910010] |Root password not working to log in to Gnome with gdm [131085910020] |I have a weird issue going on. [131085910030] |I have a user account and I can login to Gnome normally. [131085910040] |From a terminal there I can use su root and switch to root with my root password. [131085910050] |However, when I try to login to Gnome as root, the same password does not work. [131085910060] |I'm using Fedora 13 on a Dell Inspiron 6400 [131085920010] |You're not allowed to log in to the desktop as root by default. [131085920020] |See Enabling Root User for GNOME Display Manager, which says: [131085920030] |
  • Log in as a regular user and open a terminal and run su -c 'gedit /etc/pam.d/gdm-password'
  • [131085920040] |
  • Change auth required pam_succeed_if.so user != root quiet to # auth required pam_succeed_if.so user != root quiet
  • [131085920050] |
  • Save the file
  • [131085920060] |See also GDM Root Login. [131085930010] |I haven't tried this myself, but I found it here. [131085930020] |
  • Comment out this line auth required pam_succeed_if.so user != root quiet from "/etc/pam.d/gdm".
  • [131085930030] |
  • Comment out the same line from "/etc/pam.d/gdm-password".
  • [131085930040] |After that, log out and log in as root and see if it works. [131085930050] |NOTE: It's isn't automatic because it's not recommended to log in as root. [131085940010] |How can I add a line to multiple files in a directory tree structure? [131085940020] |Adding a line to multiple files in the same structure is not very hard, but I am stumped on how to do it over a possibly large directory tree structure. [131085940030] |So lets say we have your project directory, which has hundreds of projects in it and you want to add a header to every *.c file. [131085940040] |How can this be done? remember the files could be quite deep. [131085960010] |Example value for a nautilus (file manager) connect to service custom location. [131085960020] |I am looking for an example for a nautilus (fie manager) connect to service custom location. [131085960030] |Activate connection editor: [131085960040] |I am looking for an example or two for "Location" in the pop up: [131085960050] |Service Type values are: [131085960060] |
  • SSH -FTP (with login)
  • [131085960070] |
  • Public FTP
  • [131085960080] |
  • Windows Share
  • [131085960090] |
  • WebDAV (HTTP)
  • [131085960100] |
  • Secure WebDAV (HTTPS)
  • [131085960110] |
  • Custom Location
  • [131085970010] |From the nautilus user guide: [131085970020] |If the server information is provided in the form of a URI, or you require a specialized connection, choose Custom Location as the service type. [131085970030] |I have no idea what that actually entails. [131085970040] |I tried smb and ftp servers and was told I must enter a name for the server. [131085970050] |Maybe someone else knows more. [131085980010] |Removing the [ OK ] From start_udev [131085980020] |Under /sbin/start_udev, how can I remove the [ OK ] so it's not printed? [131085980030] |I'm trying to change /etc/rc.sysinit to display the information I like, and I have managed to remove all the info output apart from the annoying [ OK ] [131085980040] |Any ideas? [131085980050] |I'm using Fedora 13 [131085990010] |This is all controlled by /etc/sysconfig/init. [131085990020] |I'm pretty sure all you have to do is change it from [131085990030] |to [131085990040] |After doing that, it should change from something like: [131085990050] |to [131085990060] |Have a look at /etc/init.d/functions to see how that works. [131085990070] |start_udev calls success to print the [ OK ] message, and /etc/init.d/functions is where success is defined. [131086000010] |How can I see dumps of wholе HTTP packets? [131086000020] |I need to see whole HTTP packets sent and recieved by an application for debugging purposes. [131086000030] |How can this be done in command-line? [131086010010] |Use tcpdump. [131086010020] |tcpdump -w httpdebug.pcap -i eth0 port 80 will sniff all packets heading to or from port 80 on the eth0 interface and output them to httpdebug.pcap, which you can then read at your leisure, either with tcpdump again (with multiple -x options, refer to the tcpdump manpage ) in console if you're feeling masochistic, or with wireshark. [131086010030] |I really can't recommend the latter highly enough, as it will let you sort out packets and follow the exact stream you want to see. [131086020010] |If you really want to use command line for this there is tcpflow. [131086020020] |It saves TCP streams to different files. [131086020030] |The HTTP request and responses will be stored separately. [131086020040] |If you can use GUI try Wireshark. [131086020050] |You can right click any packet and pick "Follow TCP stream". [131086030010] |Why curl -O -C on mac fails to download [131086030020] |The following script works on Ubuntu, but not on Mac. [131086030030] |Why? [131086030040] |How to edit it so that it would work there too? [131086030050] |The output on the mac: [131086030060] |$ md5 dp4j-1.1-jar-with-dependencies.jar MD5 (dp4j-1.1-jar-with-dependencies.jar) = eb04d0d357fd861ac414fde7d3530119 [131086040010] |Have you checked if you're actually getting a .jar file?. [131086040020] |Many download links do a silent redirect to where the file actually is, so you might be downloading only a few bytes with a Location: ... redirect which CURL isn't following. [131086040030] |Open up the .jar file in a text editor and see what you've got. [131086040040] |A real .jar should start with 'PK' (since it's a .zip file). [131086050010] |curl -L [131086050020] |works. [131086050030] |It even follows redirects. [131086050040] |I found this out in this answer. [131086050050] |Refer to working script. [131086060010] |Which is the safest way to get root privileges: sudo, su or login? [131086060020] |I would like to have the root account in safety even if my unprivileged user is compromised. [131086060030] |On Ubuntu you can only use sudo for "security reasons" by default. [131086060040] |However I am not sure it is any safer than just using login on a text-mode console. [131086060050] |There are too many things that can go wrong if an attacker can run code as my normal user. [131086060060] |For example adding aliases, adding stuff to my PATH, setting LD_PRELOAD and X11 keyloggers just to mention a few. [131086060070] |The only advantage I can see is the timeout so I never forget to log out. [131086060080] |I have the same doubts about su but it doesn't even have time limit. [131086060090] |Some operations (especially IO redirection) are more convinient with su but security-wise this seems to be worse. [131086060100] |Login on a text-mode console seems to be the safest. [131086060110] |Since it is started by init if an attacker can control PATH or LD_PRELOAD he is already root. [131086060120] |The keypress events can't be intercepted by programs running on X. I don't know if programs running on X can intercept [ctrl]+[alt]+[f1] (and open a fullscreen window that looks like a console) or it is safe like [ctrl]+[alt]+[del] on Windows. [131086060130] |Besides that the only problem I see is the lack of timeout. [131086060140] |So am I missing something? [131086060150] |Why did the Ubuntu guys decide to only allow sudo? [131086060160] |What can I do to improve the security of any of the methods? [131086060170] |What about SSH? [131086060180] |Traditionally root can't log in through SSH. [131086060190] |But using the above logic wouldn't this be the safest thing to do: [131086060200] |
  • allow root through SSH
  • [131086060210] |
  • switch to text-mode
  • [131086060220] |
  • log in as root
  • [131086060230] |
  • ssh to the other machine
  • [131086060240] |
  • log in as root?
  • [131086070010] |You seem to be assuming that using sudo always preserves environment variables, but this is not always the case. [131086070020] |Here is an excerpt from the sudo manpage: [131086070030] |There are two distinct ways to deal with environment variables. [131086070040] |By default, the env_reset sudoers option is enabled. [131086070050] |This causes commands to be executed with a minimal environment containing TERM, PATH, HOME, SHELL, LOGNAME, USER and USERNAME in addition to variables from the invoking process permitted by the env_check and env_keep sudoers options. [131086070060] |There is effectively a whitelist for environment variables. [131086070070] |If, however, the env_reset option is disabled in sudoers, any variables not explicitly denied by the env_check and env_delete options are inherited from the invoking process. [131086070080] |In this case, env_check and env_delete behave like a blacklist. [131086070090] |Since it is not possible to blacklist all potentially dangerous environment variables, use of the default env_reset behavior is encouraged. [131086070100] |In all cases, environment variables with a value beginning with () are removed as they could be interpreted as bash functions. [131086070110] |The list of environment variables that sudo allows or denies is contained in the output of sudo -V when run as root. [131086070120] |So if env_reset is enabled (the default), an attacker can't override your PATH or other environment variables (unless you specifically add them to a whitelist of variables which should be preserved). [131086080010] |The safest approach is ssh login using (at least) 2048 long key (with password login disabled) using a physical device to store the key. [131086090010] |Security is always about trade-off. [131086090020] |Root would be most secure if there were no way to access it at all. [131086090030] |I notice that your LD_PRELOAD and PATH attacks assume an attacker with acesss to your account already, or at least to your dotfiles. [131086090040] |Sudo doesn't protect against that very well at all — if they have your password, after all, no need to try tricking you for later... they can just use sudo now. [131086090050] |Another thing to think about is what Sudo was designed for originally: delegation of specific commands (like those to manage printers) to "sub-administrators" (perhaps grad students in a lab) without giving away root completely. [131086090060] |Using sudo to do everything is the most common use I see now, but it's not necessarily the problem the program was meant to solve (hence the ridiculously complicated config file syntax). [131086090070] |But, sudo-for-unrestricted-root does attempt to address another security problem: manageability of root passwords. [131086090080] |At many organizations, these tend to be passed around like candy, written on whiteboards, and left the same forever. [131086090090] |That leaves a big vulnerability, since revoking or changing access becomes a big production number. [131086090100] |Even keeping track of what machine has what password becomes a challenge — let alone who knows which one. [131086090110] |And, remember that most "cyber-crime" comes from within. [131086090120] |With the root password situation described, it's hard to track down who did what — something sudo with remote logging deals with pretty well. [131086090130] |On your home system, I think it's really more a matter of the convenience of not having to remember two passwords. [131086090140] |It's probable that many people were simply setting them to be the same — or worse, setting them to be the same initially and then letting them get out of sync, leaving the root password to rot. [131086090150] |Using passwords at all for SSH is dangerous, since password-sniffing trojaned ssh daemons are put into place in something like 90% of the real-world system compromises I've seen. [131086090160] |It's much better to use SSH keys, and this can be a workable system for remote root access as well. [131086090170] |But the problem there is now you've moved from password management to key management, and ssh keys aren't really very manageable. [131086090180] |There's no way of restricting copies, and if someone does make a copy, they have all the attempts they want to brute-force the passphrase. [131086090190] |You can make policy saying that keys must be stored on removable devices and only mounted when needed, but there's no way of enforcing that — and now you've introduced the possibility of a removable device getting lost or stolen. [131086090200] |The highest security is going to come through one-time keys or time/counter-based cryptographic tokens. [131086090210] |These can be done in software, but tamper-resistant hardware is even better. [131086090220] |In the open source world, there's WiKiD and YubiKey, and of course there's also the proprietary heavyweight RSA SecurID. [131086090230] |If you're in a medium-to-large organization, or even a security-conscious small one, I highly recommend looking into one of these approaches for administrative access. [131086090240] |It's probably overkill for home, though, where you don't really have the management hassles — as long as you follow sensible security practices. [131086100010] |This is a very complex question. mattdm has already covered many points. [131086100020] |Between su and sudo, when you consider a single user, su is a little more secure in that an attacker who has found your password can't gain root privileges immediately. [131086100030] |But all it takes is for the attacker to find a local root hole (relatively uncommon) or install a trojan and wait for you to run su. [131086100040] |Sudo has advantages even over a console login when there are multiple users. [131086100050] |For example, if a system is configured with remote tamper-proof logs, you can always find out who last ran sudo (or whose account was compromised), but you don't know who typed the root password on the console. [131086100060] |I suspect Ubuntu's decision was partly in the interest of simplicity (only one password to remember) and partly in the interest of security and ease of credential distribution on shared machines (business or family). [131086100070] |Linux doesn't have a secure attention key or other secure user interface for authentication. [131086100080] |As far as I know even OpenBSD doesn't have any. [131086100090] |If you're that concerned about root access, you could disable root access from a running system altogether: if you want to be root, you would need to type something at the bootloader prompt. [131086100100] |This is obviously not suitable for all use cases. (*BSD's securelevel works like this: at a high securelevel, there are things you can't do without rebooting, such as lowering the securelevel or accessing mounted raw devices directly.) [131086100110] |Restricting the ways one can become root is not always a gain for security. [131086100120] |Remember the third member of the security triad: confidentiality, integrity, availability. [131086100130] |Locking yourself out of your system can prevent you from responding to an incident. [131086110010] |Agree with Let_Me_Be. [131086110020] |Also agree with you about sudo not being anymore secure than using the root account itself. [131086110030] |It pains me hearing people talk out of their ass on how you should never use the root account directly ... [131086110040] |Sudo was meant to give access to only specific commands, but even even using it that way it is very easy to configure incorrectly and leave a big gaping hole. [131086110050] |What I do is disable passwords via SSH and make everyone use keys. [131086110060] |Depending on the box, I'll either put people's keys in root's auth keys or to their own user and add them to wheel. [131086110070] |sudo is annoying and gives people a false sense of security. [131086120010] |The designers of the secured OpenWall GNU/*/Linux distro have also expressed critical opinions on su (for becoming root) and sudo. [131086120020] |You might be interested in reading this thread: [131086120030] |...unfortunately both su and sudo are subtly but fundamentally flawed. [131086120040] |Apart from discussing the flaws of su and other things, Solar Designer also targets one specific reason to use su: [131086120050] |Yes, it used to be common sysadmin wisdom to "su root" rather than login as root. [131086120060] |Those few who, when asked, could actually come up with a valid reason for this preference would refer to the better accountability achieved with this approach. [131086120070] |Yes, this really is a good reason in favor of this approach. [131086120080] |But it's also the only one. ...(read more) [131086120090] |In their distro, they have "completely got rid of SUID root programs in the default install" (i.e., including su; and they do not use capabilities for this): [131086120100] |For servers, I think people need to reconsider and, in most cases, disallow invocation of su and sudo by the users. [131086120110] |There's no added security from the old "login as non-root, then su or sudo to root" sysadmin "wisdom", as compared to logging in as non-root and as root directly (two separate sessions). [131086120120] |On the contrary, the latter approach is the only correct one, from a security standpoint: [131086120130] |http://www.openwall.com/lists/owl-users/2004/10/20/6 [131086120140] |(For accountability of multiple sysadmins, the system needs to support having multiple root-privileged accounts, like Owl does.) [131086120150] |(For desktops with X, this gets trickier.) [131086120160] |You also absolutely have to deal with... [131086120170] |BTW, they were to replace sulogin with msulogin to allow the setup with multiple root accounts: msulogin allows one to type in the user name also when going into the single user mode (and preserve the "accountability") (this info comes from this discussion in Russian). [131086130010] |If the concern is that a compromised user account can be used to sniff the password used for sudo or su, then use a one-time passcode for sudo and su. [131086130020] |You can force the use of keys for remote users, but that might not pass muster for compliance purposes. [131086130030] |It might be more effective to setup an SSH gateway box that requires two-factor auth, then permit key use from there. here's a doc on such a setup: http://www.howtoforge.com/secure_ssh_with_wikid_two_factor_authentication [131086140010] |I just want to add something a bit off topic. (for the topic one check '/bin/su -' here after) [131086140020] |I think that the above "security" should also be linked to the actual data we want to secure. [131086140030] |It will and it should be different if we want to secure: my_data, my_company_data, my_company_network. [131086140040] |Usually, if I speak about security I also speak about "data security" and backup. [131086140050] |We can also add fault-tolerant systems and the like. [131086140060] |Given this, I think that security as a whole is an equilibrium between the usability, the "data security" and the required effort to implement a secure system. [131086140070] |Ubuntu's target was, and mostly still is, the final user: Sudo is the default. [131086140080] |Fedora is the free version of RedHat which in turn is more servers oriented: Sudo used to be disabled. [131086140090] |For the other distributions I have no direct information. [131086140100] |I am using right now, mostly, fedora. [131086140110] |And as an old style user I never typed 'su'. [131086140120] |But I can type "/bin/su -" in a very short time even if I am not exactly a typist. [131086140130] |The PATH variable.. should not be a problem (I type the path). Also the "-" (minus) in principle should remove my user environment variables and load only the root ones. i.e. avoiding some extra possible troubles. [131086140140] |Probably also the LS_PRELOAD. [131086140150] |For the rest I guess that @mattdm was pretty precise. [131086140160] |But lets put it in the correct box. [131086140170] |Assume that a scripting smart kit get access to my data. [131086140180] |What the hell do you think is he going to do with it? - Publish my pictures? my? - Trying to find out my girlfriend name and tell her that I visit porno sites? [131086140190] |In the single user picture the two worst situations are: - The kid delete all my data: for fun or by mistake - The kid uses my machine to create a further attack to some other entity. [131086140200] |Or similar targets. [131086140210] |For the first case, I mentioned above, better putting efforts on a backup than on network security. [131086140220] |Yep, you are save. [131086140230] |I mean an hardware crash is not that different. [131086140240] |The second case is more subtle. [131086140250] |But there are signals about these activities. [131086140260] |In any case, you can do the possible, but I would not configure my home PC to be protected from a terroristic attacks! [131086140270] |I will skip the other scenarios. [131086140280] |cheers F