[131008750010] |
cut -d ' ' -f -1
but what I get is:
[131008760050] |How can i preserve line endings in the file?
[131008770010] |file contents
[131008770020] |getting the first column only
[131008770030] |getting the first and third column, this time from stdin through a pipe
[131008770040] |EDIT: I think I know what you're doing wrong
[131008780010] |find . -name '*.flac' -exec ~/bin/flac2mp3 '{}' \;
in ~/Desktop/stack gives the following output:
[131008780120] |id3info
for the original .flac and resultant .mp3 gives, respectively:
[131008780130] |(i.e. nothing);
[131008780140] |The .flac definitely has tag information.
[131008780150] |I can verify this by opening up EasyTAG.
[131008780160] |EasyTAG refers to this as 'FLAC Vorbis Tag' but 'ID3 Tag' for the .mp3.
[131008780170] |Is this the problem?
[131008800010] |-lm
when using functions from math.h
if you want to keep your code/makefiles portable.
[131008810020] |Some of the things in that header are macros (which obviously don't need additional libraries), but which are is not specified (except for a few ones).
[131008810030] |Some other functions might be implemented as build-ins by your compiler (even replaced by processor-specific opcodes directly), inlined, etc... so the correct linking of your code could also depend on optimizer settings and the exact compiler/version you're using.
[131008810040] |For example:
[131008810050] |With GCC 4.5.1 on Linux:
[131008810060] |So to save yourself a headache, just add -lm
.
[131008820010] |pacman
while other packages still depend upon it.
[131008820030] |basically LWP 6 split a whole bunch of packages, and I need to remove it so I can reinstall it.
[131008830010] |You should be able to reinstall the package with a simple:
[131008830020] |This will only remove perl-libwww:
[131008830030] |Please notice the double -d in the command, if you use --nodeps you have to specify that twice too or combine it with a -d like:
[131008830040] |This removes all the packages which depend on perl-libwww:
[131008830050] |From pacman's man page:
[131008840010] |+
putton in the Items tab.
[131008860010] |From the command line, try moving ~/.config/xfce4/panel to another directory (e.g. ~/tmp/): mkdir -p ~/tmp; mv ~/.config/xfce4/panel ~/tmp/
.
[131008860020] |But a more "safe" way would be to create a new panel (right click on the panel and choose "Customize Panel...".
[131008860030] |From there, create a new panel with the appearance and position of the one you have now.
[131008860040] |When that has been created, delete the first panel.
[131008870010] |vim
?
[131008870030] |I'd like have each line wrap at 80 characters, not just visually wrap but enter a newline.
[131008870040] |I got this kind of working by using
[131008870050] |But if I go back and insert text on a previous line, it doesn't adjust the rest of the paragraph.
[131008870060] |It takes the overflow text and puts it on a newline, but the line that comes after doesn't get moved up to fill in the gap.
[131008870070] |So if I edit a previous line, my paragraph can look like this
[131008870080] |I want it to be like this:
[131008880010] |wrap
and linebreak
control the display of text, I think you'll find they don't actually insert newlines in the file.
[131008880020] |To get vim to insert newlines in the file as you type, set textwidth
to the desired width (e.g. 80).
[131008880030] |That will still not automatically reflow subsequent lines when you insert more text.
[131008880040] |I usually do that manually with gq}
, but I just discovered that set formatoptions+=a
will tell vim to do it automatically.
[131008880050] |See the help for auto-format
.
[131008890010] |The gq}
wraps a paragraph to textwidth
.
[131008890020] |Be sure to set tw=80
first.
[131008890030] |Many distros map that to Q.
[131008890040] |So you may also be able to also use Q}
instead.
[131008900010] |I use par
for formatting, it can even word wrap with an existing prefix, in the context of emails for example.
[131008910010] |-p
, --proxyhost
, etc. args.
[131008940030] |(These are simply supplied after the single -c option's IP address.)
[131008940040] |There are some examples on the pwnat home page I've linked to above that should help if you're still stuck.
[131008950010] |Where did you get --proxyhost
from??
[131008950020] |The documentation gives an example:
[131008950030] |So try this:
[131008960010] |echo $PATH
gives (except space delimited rather than colon).
[131008960050] |Running ksh again does not appear to change my path, but now the script is not found.
[131008960060] |This is as a normal user running ksh on AIX 6.1 over telnet (yeah, I know).
[131008970010] |which
is a csh script on AIX, and it might use a different path.
[131008970020] |But that doesn't seem to be exactly your problem, since which
prints the expected path.
[131008970030] |Are you absolutely sure you didn't have a different path in the first ksh
session?
[131008970040] |Running ksh again might have changed the PATH
because it ran ~/.kshrc
or $ENV
.
[131008970050] |(And just to be sure, does the script still exist, or could it simply have been deleted in the meantime?)
[131008980010] |Running type $scriptname
told me that it was an alias.
[131008980020] |Apparently this prevented it from being found by which.
[131008990010] |(load-library “init_python”)
in your .emacs
[131008990040] |How can I do this?
[131009000010] |To quote the Emacs manual on The Init File:
[131009000020] |When Emacs is started, it normally tries to load a Lisp program from an initialization file, or init file for short.
[131009000030] |This file, if it exists, specifies how to initialize Emacs for you.
[131009000040] |Emacs looks for your init file using the filenames ~/.emacs
, ~/.emacs.el
, or ~/.emacs.d/init.el
; you can choose to use any one of these three names.
[131009000050] |Here, ~/
stands for your home directory.
[131009000060] |Originally, Emacs looked only for ~/.emacs
.
[131009000070] |The variant names were introduced in more recent versions of Emacs.
[131009000080] |So, in this case:
[131009000090] |Type C-x C-f ~/.emacs
to load or create your .emacs
file.
[131009000100] |Type (load-library “init_python”)
into that file.
[131009000110] |Type C-x C-s
to save it.
[131009010010] |^oldfile^newfile
) with the n th-last command?
[131009010050] |I have (unsuccessfully) tried to pipe the n th-last command into the substitution like so:
[131009010060] |Of course, I am open to other suggestions.
[131009010070] |These little shortcuts really help with productivity...
[131009020010] |You could write lengthy command as a shell function that takes a filename as a parameter and then just type function filename
when you need it.
[131009030010] |You can't do it with a quick substitution directly, because ^foo^bar
is shorthand for:
[131009030020] |The !!
part (which refers to the last command) isn't part of the quick syntax (that's what makes it quick), but you can use the longer syntax directly and then modify the !!
to whatever you want:
[131009030030] |I explained as much of the history syntax as I know in this post; the last section includes the :s
modifier
[131009040010] |students.txt
and it contains the following data in the format Surname, Forename: day.month.year: Degree
:
[131009040030] |I'm trying to return all lines in the format Forename,Surname: day.month.year
, but without the MSc
degree being studied.
[131009040040] |So far I have:
[131009040050] |What's wrong with that?
[131009050010] |Rather than sed, it might be easier use awk with a field separator of ':', and just print the first two fields.
[131009060010] |This should do it:
[131009060020] |The first statement (separated by ;
) searches for the Surname, delimited by comma-space, and Forename, delimited by colon, and swaps them, using a comma-space separator.
[131009060030] |The second statement searches for the last colon and removes that and anything to the end of the line.
[131009060040] |As someone mentioned this could be handled by awk.
[131009060050] |Q.E.D
[131009070010] |For sed
you'll want three back references.
[131009070020] |The first delimited by the comma and the second two delimited by the colon
[131009070030] |However, when dealing with delimiter and fields, awk
is really the tool to use because you can specify a field separator which can be a regex.
[131009070040] |In this case our field separator is either a comma or colon folowed by a space.
[131009080010] |x.x.x.x/y
is the cidr of the wireless network.
[131009100020] |This should capture anything coming or going to this network and save it to "capturefile" file.
[131009100030] |Add and port 80
in the end if you want only web traffic.
[131009100040] |This looks like a "honeypot" setup.
[131009100050] |If you are trying to capture http sessions and/or other private information, this is illegal.
[131009100060] |Even if those users are trying to steal your internet connection.
[131009100070] |Unless you've acquired permission from those who use the wireless network, this is probably illegal.
[131009100080] |EDIT:
[131009100090] |I thought you already had setup the rerouting part.
[131009100100] |If you're asking how to reroute the specific traffic, it is possible but it depends on the hardware you have and probably I can't help you on that.
[131009110010] |You can connect modem directly to your computer and make router so send all traffic through your debian system.
[131009110020] |In this case you may do anything you want with packets.
[131009110030] |P.S.: do you need something like this?
[131009120010] |Get a 10/100 ethernet hub, a real hub, like a Netgear DS104.
[131009120020] |Put it between the wifi and the router.
[131009120030] |Hubs replicate traffic on all ports, so you can connect a separate machine to another port on the hub and sniff everything.
[131009130010] |yum
to upgrade the OS entirely to the latest version?
[131009130050] |At present there are no .repo
files in my /etc/yum.repos.d/
directory.
[131009130060] |So I could not use the yum
command.
[131009130070] |How to get the necessary repository and to upgrade the OS?
[131009140010] |I don't think using yum is feasible for such an early release of Fedora.
[131009140020] |I seem to remember having trauma upgrading an FC4 system.
[131009140030] |My best advice is to:
[131009140040] |/proc/sys/vm/swappiness
is nice but i want a knob that's per process like /proc/$PID/oom_adj
so that i can make certain processes less likely than others to have any of their pages swapped out unlike memlock this doesn't prevent a program from being swapped and like nice the user by default can't make their programs less likely but only more likely to get swapped i think i'd a call this /proc/$PID/swappiness_adj
[131009180010] |You can configure swappiness per cgroup:
[131009180020] |http://www.kernel.org/doc/Documentation/cgroups/cgroups.txt
[131009180030] |http://www.kernel.org/doc/Documentation/cgroups/memory.txt
[131009190010] |eth0
is on the IP 172.16.109.75 My wifi adaptor wlan0
is on the IP 192.168.1.69
[131009190040] |When I ping google with my eth0
unplugged with the following command:
[131009190050] |It works fine as expected.
[131009190060] |I plug my eth0
cable in and run the same again:
[131009190070] |By the output at the top it seems to send it from the eth0
(which at work won't be able to ping because it gets blocked), but the wifi
is another link to a separate network where I'm on the net directly and therefore sending the ping request from the wlan0
should work.
[131009190080] |What's happening?
[131009190090] |How should I fix it?
[131009200010] |Probably, when pluging in the ethernet cable, your default route gateway changes by dhcp.
[131009200020] |You send packets from wlan0 but your system doesn't know who is the gateway to forward them to.
[131009200030] |This way you can only ping systems within 192.168.1 network but not further.
[131009200040] |If you want to get a reply from the google server, you'll have to either change the default gateway back to the wireless router, or add a specific route for this server.
[131009210010] |To ping from some interface you should use:
[131009220010] |preexec
function erases the second line before running the command; if you want to keep it, change to preexec () { echo; }
.
[131009250040] |%
escapes are documented in the zsh manual (man zshmisc
).
[131009250050] |Terminfo is a terminal access API.
[131009250060] |Zsh has a terminfo
module that gives access to the terminal description database: $terminfo[$cap]
is the sequence of characters to send to exercise the terminal's capability $cap
, i.e., to run its $cap
command.
[131009250070] |See man 5 terminfo
(on Linux, the section number may vary on other unices) for more information.
[131009250080] |The sequence of actions is: move the cursor down one line (cud1
), then back up (cuu1
); save the cursor position (sc
); move the cursor down one line; print [some status]
; restore the cursor position.
[131009250090] |The down-and-up bit at the beginning is only necessary in case the prompt is on the bottom line of the screen.
[131009250100] |The preexec line erases the second line (el
) so that it doesn't get mixed up with output from the command.
[131009250110] |If the text on the second line is wider than the terminal, the display may be garbled.
[131009250120] |Use Ctrl+L in a pinch to repair.
[131009260010] |Here is a bash
equivalent of Gilles' zsh solution.
[131009260020] |Bash doesn't have a native terminfo module, but the tput
command (bundled with terminfo
) does much the same thing.
[131009260030] |If the terminal doesn't support one of the capabilities, it will fall back to a one-line prompt.
[131009260040] |The trap
line is a hacky way to emulate zsh's preexec
function.
[131009260050] |See http://superuser.com/questions/175799/ for more info.
[131009260060] |EDIT: Improved script based on Gilles' comments.
[131009270010] |.deb
file is not its concern.
[131009280030] |Apt doesn't track this information either, but it knows where you can now get the package, which is good enough.
[131009280040] |As 9000 wrote in a comment, apt-cache policy '^libav'
shows you what versions of packages with names matching the regexp ^libav
are installed or available.
[131009280050] |The output isn't particularly convenient to parse, but here's a minimally tested script that gives approximately the format you want:
[131009280060] |Another way to the information you're asking for is with aptitude versions
.
[131009280070] |Again, the minimally-tested snippet below gives roughly the desired format.
[131009280080] |The pattern "^libav" ~i
matches packages that are installed and whose name matches the given regexp.
[131009280090] |There's also a separately-packages utility apt-show-versions
that, again, gives the information you want in roughly the format you're asking.
[131009290010] |as an example. [131009290090] |Edited the question to use {,} [131009300010] |XML like expressions (infinintely recursive tags) is not a 'regular language' therefore cannot be parsed with regular expressions (regex). [131009300020] |Here's why: [131009300030] |http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/ [131009300040] |http://www.perlmonks.org/?node_id=668353 [131009300050] |http://stackoverflow.com/questions/1379524/textual-protocol-which-is-not-a-regular-language [131009310010] |Regular expressions cannot find matching nested parentheses. [131009310020] |If you are certain that there will be no pair of parentheses nested inside the one you are searching, you can search until the first closing one. [131009310030] |For example: [131009310040] |This will replace all the text from '{' to '}' with what's between them. [131009320010] |You can use the -M (multiline) option for pcregrep: [131009320020] |\s is whitespace (including newlines), so this matches zero or more occurrences of (whitespace followed by .* followed by whitespace), all enclosed in braces. [131009320030] |Update: [131009320040] |This should do the non-greedy matching: [131009330010] |While I agree with the advice above, that you'll want to get a parser for anything more than tiny or completely ad-hoc, it is (barely ;-) possible to match multi-line blocks between curly braces with sed. [131009330020] |Here's a debugging version of the sed code [131009330030] |Some notes, [131009330040] |
/[{]/,/[}]/
is a range expression.
[131009330070] |It means scan until you find something that matches the first pattern (/[{]/)
AND then scan until you find the 2nd pattern (/[}]/)
THEN perform whatever actions you find in between the { } in the sed code.
[131009330080] |In this case 'p' and the debugging code. (not explained here, use it, mod it or take it out as works best for you).-q
option you can control how many packets are sent:
[131009360010] |The hosts shown by traceroute are not servers, they're routers.
[131009360020] |Traceroute shows the hops on the IP route from the computer of the person who took this snapshot to the wikipedia server.
[131009360030] |The description of HTTP that you quote looks at a much higher level where all this routing is transparent.
[131009360040] |I think the best way of explaining this is through a metaphor.
[131009360050] |HTTP (for example) requires a bidirectional communication channel between the client and the server; this channel is provided by TCP.
[131009360060] |TCP is built in turn on top of IP.
[131009360070] |The goal of IP is to transmit packets from one IP address to another.
[131009360080] |An TCP connection requires IP packets going from the client to the server and IP packets going from the server to the client.
[131009360090] |Ok, now think of each IP packet as a letter that you drop in a mail box and that the Post Office carries to its destination.
[131009360100] |Traceroute shows all the stages on the journey of the letter from your dwelling to the recipient's dwelling: the mail box it's dropped in, the town post office, the district sorting office, the regional mail hub, etc., until the letter reaches the recipient's mail slot.
[131009360110] |This is basically what you see when you watch the progress of a registered tracked parcel with DHL/UPS/...
[131009360120] |In this example, the first two hops are called ….xs4all.net
; they're clearly from the snapshot author's ISP.
[131009360130] |The next few lines are from WV Fiber, which operates international transit lines.
[131009360140] |I don't know who as30217.net
is; probably an ISP for datacenters.
[131009360150] |The final two machines are from Wikipedia.
[131009360160] |IP routing is completely transparent to higher-level protocols such as TCP and a fortiori all protocols built over TCP.
[131009360170] |In fact, traceroute has to play some tricks to obtain the information at all.
[131009370010] |$?
) conflates the actual exit status of the program and the signal value: if a program is killed by a signal, $?
is set to a value greater than 128 (on every unix I know, this value is 128 plus the signal number).
[131009400080] |In particular, if $?
is 0, your program exited normally.
[131009400090] |¹ roughly speaking
[131009410010] |/usr/local/xxxx/check-interface.bash
with something dead simple, like:
[131009420050] |And then see if /tmp/check-interfaces.log is actually being populated by your cronjob.
[131009420060] |If it does work, then the problem must be with your original script.
[131009430010] |.ssh
with files inside.
[131009450030] |If .ssh
doesn't exist, you don't have any key set up, so you have to generate a pair using ssh-keygen
(it defaults to create the keys in ~/.ssh
, you can give the keys a password or not).
[131009450040] |This will give you a .pub file in ~/.ssh
(mine is id_rsa.pub
).
[131009450050] |The file id_rsa.pub
should look like:
[131009450060] |ssh-rsa lotsofrandomtext user@local
[131009450070] |Second, ssh to the server, check to see if you have a file named ~/.ssh/authorized_keys
, create it if it doesn't exist.
[131009450080] |Then, append the contents of the ~/.ssh/id_rsa.pub
that you generated earlier in your local machine here.
[131009450090] |This might mean copying the file contents to your clipboard, then opening ~/.ssh/authorized_keys
in a text editor and pasting the lines in.
[131009450100] |You should now be able to ssh without typing the password.
[131009450110] |Third, if you put this in ~/.ssh/config
:
[131009450120] |You will be able to ssh server
(save quite a few key strokes).
[131009450130] |Thanks to cjm for the User
keyword that I forgot to mention.
[131009460010] |As a supplement to phunehehe's answer, see the Gentoo Linux Keychain Guide for a guide to keychain. keychain also uses ssh-agent.
[131009460020] |The ssh-agent daemon makes the passphrase available (it becomes unavailable when the ssh-agent daemon dies) but keychain reuses an ssh-agent between logins, and optionally prompts for passphrases each time the user logs in
, to quote the guide.
[131009470010] |http.tcl
script:
[131009470030] |conflicting versions provided for package "http": 2.7.5, then 2.5.2
[131009470040] |How do I fix this?
[131009480010] |/dev/tunX
looks like incoming packets for network stack.
[131009490060] |In usual tunneling setup server and client have TUN devices with assigned addresses.
[131009490070] |Routing tables configured on both of them directs needed traffic to this TUN devices.
[131009490080] |When packet get routed to tun0, kernel sends it to userspace program (client) that sends this packet to other program on remote machine (server) via, for example, TCP connection. On remote machine other program (server) recieves packet from client and writes it to it's own /dev/tunX
device, "injecting" that packet into network stack.
[131009490090] |And tunneled packet gets processed as any other.
[131009500010] |iconv
to it.
[131009500030] |This gets output in STDOUT.
[131009500040] |Since adding the -o
parameter ( in my experience ) actually writes a blank file probably before the conversion takes place, how can I adjust my script so it does the conversion, then overwrites the input file?
[131009510010] |This isn't working because iconv
first creates the output file (since the file already exists, it truncates it), then starts reading its input file (which is now empty).
[131009510020] |Most programs behave this way.
[131009510030] |Create a new, temporary file for the output, then move it into place.
[131009510040] |Colin Watson's sponge
utility (included in Joey Hess's moreutils) automates this:
[131009520010] |python
and python-devel
).
[131009560030] |I'd really like to just get the entire standard library when I install it, since that's how it's designed to work.
[131009560040] |Thanks.
[131009560050] |UPDATE: Some people are wondering what I mean, so here's an example: https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/123755.
[131009560060] |I realize it's not caused (in this instance) by a python
/python-devel
split, but it's the sort of issue I don't want to worry about.
[131009560070] |I just want to install the entirety of Python—with no weird tweaks of the ImportError
handler, or std lib modules ripped out (for any reason)—and then let my package manager handle security updates, etc.
[131009570010] |Well, there's Gentoo.
[131009570020] |Since it installs everything from source, there are no -dev
packages.
[131009580010] |On Debian (and therefore probably Ubuntu), running apt-get install python
installs python-minimal
and python
, which results in all core modules being installed, which I assume is what you mean by "the entire standard library".
[131009580020] |The only caveat I can find is that the Tk GUI stuff is all installed, but you need to install the python-tk
package to use it properly.
[131009580030] |So run apt-get install python python-tk
, and you have everything you need.
[131009580040] |Does that meet your criteria?
[131009590010] |Arch Linux doesn't have separate packages for -dev
and it's binary (unlike gentoo).
[131009590020] |There might be a few things, like tk
which isn't pulled in by default.
[131009590030] |Here's the python package
for arch.
[131009600010] |netdev=
kernel command line parameter (you need to pass that to the kernel in grub) to instruct the kernel to link a given irq to a given interface, e.g.: netdev=irq=2,name=eth0
[131009620010] |You are likely going to have to go into each affected programs configuration files and change 'eth1' to 'eth0.'
[131009620020] |Such programs defaults are setup when they are installed or first run with the currently detected NICs.
[131009620030] |I use Linux as a router, and had this issue when using scripts.
[131009620040] |I now have a nice script fragment called netconf
that I source in for any other script whenever i need to use NIC names, this file gives me a central location to specify them (i.e. LAN_IFACE=eth0
, WAN_IFACE=eth1
, etc.)
[131009630010] |You can't change which interface is used by default in applications like iftop
.
[131009630020] |They call the C library function if_nameindex
and use the first element in the returned array by default.
[131009630030] |GNU libc's if_nameindex
on Linux is a thin wrapper around the SIOCGIFCONF
ioctl.
[131009630040] |That returns interfaces in a fixed order, based on the order in which the network drivers were initialized and the order in which each driver detected each device.
[131009630050] |If you really don't want to have to pass -i
to iftop
and similar programs, you can make a small wrapper around if_nameindex
that reorders the elements in the returned list, with LD_PRELOAD
.
[131009630060] |I would call that a lot more trouble than it's worth.
[131009640010] |I am answering to my own question now because I finally found a workaround for this problem.
[131009640020] |I found out that it is possible to reorder the devices by unloading the drivers and then loading them in correct order.
[131009640030] |update-rc.d reorder-nics start S
[131009640090] |/etc/modprobe.d/
.
[131009640130] |I created a file named "disable-nics.conf
".
[131009640140] |Note that files in /etc/modprobe.d/
must have .conf
suffix.
[131009640150] |Also naming modules in /etc/modprobe.d/blacklist.conf
do not affect autoloading of modules by the kernel so you have to make your own file.
[131009640160] |Then run 'depmod -ae' as root
[131009640170] |Recreate your initrd with 'update-initramfs -u'
[131009640180] |And finally add the driver names in corrected order into /etc/modules file.
[131009640190] |Changes should come in effect after the next boot.
[131009640200] |Reboot is not necessary though, it's easy to switch the devices with following command (as root ofcourse):
[131009640210] |Some usefull links I found while searching the solution:
[131009640220] |perl -c filename
to find unmatched curly brackets {} in arbitrary files, not necessarily Perl scripts.
[131009680030] |The problem is, it doesn't work with other types of brackets () [] and maybe <>.
[131009680040] |I also had experiments with several Vim plugins that claims to help finding unmatched brackets but so far not so good.
[131009680050] |I have a text file with quite a few brackets and one of them is missing!
[131009680060] |Is there any program / script / vim plugin / whatever that can help me identify the unmatched bracket?
[131009690010] |In Vim you can use [ and ] to quickly travel to nearest unmatched bracket of the type entered in the next keystroke.
[131009690020] |So [{ will take you back up to the nearest unmatched "{"; ]) would take you ahead to the nearest unmatched ")", and so on.
[131009700010] |The best option is vim/gvim as identified by Shadur, but if you want a script, you can check my answer to a similar question on Stack Overflow.
[131009700020] |I repeat my whole answer here:
[131009700030] |If what you are trying to do applies to a general purpose language, then this is a non-trivial problem.
[131009700040] |To start with you will have to worry about comments and strings.
[131009700050] |If you want to check this on a programming language that uses regular expressions, this will make your quest harder again.
[131009700060] |So before I can come in and give you any advice on your question I need to know the limits of your problem area.
[131009700070] |If you can guarantee that there are no strings, no comments and no regular expressions to worry about - or more generically nowhere in the code that brackets can possibly be used other than for the uses for which you are checking that they are balanced - this will make life a lot simpler.
[131009700080] |Knowing the language that you want to check would be helpful.
[131009700090] |If I take the hypothesis that there is no noise, i.e. that all brackets are useful brackets, my strategy would be iterative:
[131009700100] |I would simply look for and remove all inner bracket pairs: those that contain no brackets inside.
[131009700110] |This is best done by collapsing all lines to a single long line (and find a mechanism to to add line references, should you need to get that information out).
[131009700120] |In this case the search and replace is pretty simple:
[131009700130] |It requires an array:
[131009700140] |And a loop through those elements:
[131009700150] |My test file is as follows:
[131009700160] |My full script (without line referencing) is as follows:
[131009700170] |The output of that script stops on the innermost illegal uses of brackets.
[131009700180] |But beware: 1/ this script will not work with brackets in comments, regular expressions or strings, 2/ it does not report where in the original file the problem is located, 3/ although it will remove all balanced pairs it stops at the innermost error conditions and keeps all englobbing brackets.
[131009700190] |Point 3/ is probably an exploitable result, though I'm not sure of the reporting mechanism you had in mind.
[131009700200] |Point 2/ is relatively easy to implement but takes more than a few minutes work to produce, so I'll leave it up to you to figure out.
[131009700210] |Point 1/ is the tricky one because you enter a whole new realm of competing sometimes nested beginnings and endings, or special quoting rules for special characters...
[131009710010] |Update 2: The following script now prints out the line number and column of a mismached bracket.
[131009710020] |It processes one bracket type per scan (ie. '[]' '<>' '{}' '()' ...) The script identifies the first ,unmatched right bracket, or the first of any un-paired left bracket...
[131009710030] |On detecting an erroe, it exits with the line and column numbers
[131009710040] |Here is some sample output...
[131009710050] |Here is the script...
[131009720010] |KDE3.5
.
[131009730010] |From a Unicode and UTF-8 FAQ for UNIX/Linux: You can get a list of all locales installed on your system (usually in /usr/lib/locale/) with the command locale -a
.
[131009730020] |Set the environment variable LANG
to the name of your preferred locale.
[131009730030] |Konsole supports whatever your system supports - the important thing is that you export LANG
in your shell so that the programs you run display their characters using the correct locale.
[131009740010] |chmod 777 file
, but if I want to be sure I'm granting permission just for that user, how can I do it?
[131009740030] |-- update
[131009740040] |The file is owned by "root", so it's mine if I access it with sudo
, I suppose (or maybe I'm confused.. please correct me).
[131009740050] |I want to share a folder called /Data
in the root.
[131009740060] |The other user I want to share it is the root of an embedded system, which I'm accessing with telnet and NFS.
[131009740070] |The files inside /Data
are generated by me, and every time I generate them, I have to use the command chmod 777 /Data
so I can access them from the embedded system.
[131009740080] |I'm using Ubuntu in my computer, and a compiled-here-linux in the embedded system.
[131009750010] |You need to find a group that only you and that user is part of, and give correct permission to the group, not the world.
[131009750020] |Could be easier with access control lists, if available.
[131009760010] |If you own the file, setfacl -m u:otheruser:rwx filename
[131009760020] |If not, or if your filesystem doesn't support extended acls, I'm afraid you're out of luck.
[131009770010] |git diff
shows the subtraction of the old file followed by the addition of a new file with the same content
[131009770040] |I'm looking for a git configuration option or command-line flag that tells diff
to just ignore those -- if two lines differ only by whitespace, pretend they're the same.
[131009770050] |I need this config option/flag to work for anything that relies on file differences -- diff
, blame
, even merge
/rebase
ideally -- I want git
to completely ignore trailing whitespace, particularly line endings.
[131009770060] |How can I do that?
[131009780010] |For diff, there's git diff --ignore-space-at-eol
, which should be good enough.
[131009780020] |For diff and blame, you can ignore all whitespace changes with -w
: git diff -w
, git blame -w
.
[131009780030] |For git apply
and git rebase
, the documentation mentions --ignore-whitespace
.
[131009780040] |For merge, it looks like you need to use an external merge tool.
[131009780050] |You can use this wrapper script (untested), where favorite-mergetool
is your favorite merge tool; run git -c mergetool.nocr.cmd=/path/to/wrapper/script merge
.
[131009780060] |The result of the merge will be in unix format; if you prefer another format, convert everything to that different format, or convert $MERGED
after the merge.
[131009780070] |To minimize trouble with mixed line endings, make sure text files are declared as such.
[131009780080] |See also Is it possible for git-merge to ignore line-ending differences? on Stack Overflow.
[131009790010] |apt-get purge
not remove, probably.
[131009810030] |You want to purge this lot, at a minimum.
[131009810040] |You can do it with a wildcard or regex.
[131009810050] |seems to delete all packages beginning with cups, but really we want all files containing cups.
[131009810060] |Regex experts to the rescue, please. :-) See apt-get purge '^cups'
output below.
[131009810070] |(UPDATE: Per Paul's comments below, GNOME apparently insists on having some CUPs libraries installed, so I suggested he just remove frontend stuff, so in fact maybe he really does want apt-get purge '^cups'
).
[131009820010] |Ah — turns out I think this was actually a VMWare issue after all.
[131009820020] |I disabled printers in VMWare’s virtual machine’s settings, and lo and behold, the problem (seems to have) disappeared.
[131009820030] |VMWare must have been trying to get printing to work.
[131009830010] |lspci
[131009830090] |0000:00:00.0 Class 0604: Unknown device 1957:0070 (rev 20)
[131009830100] |0000:01:00.0 Class 0200: Unknown device 14e4:1692 (rev 01)
[131009830110] |0001:02:00.0 Class 0604: Unknown device 1957:0070 (rev 20)
[131009830120] |0001:03:00.0 Class 0200: Unknown device 14e4:1692 (rev 01)
[131009830130] |/proc/iomem
[131009830140] |a0000000-bfffffff : /pcie@ffe09000
[131009830150] |a0000000-bfffffff : PCI Bus 0000:01
[131009830160] |a0000000-a000ffff : 0000:01:00.0
[131009830170] |a0000000-a000ffff : tg3
[131009830180] |c0000000-dfffffff : /pcie@ffe0a000
[131009830190] |c0000000-dfffffff : PCI Bus 0001:03
[131009830200] |c0000000-c000ffff : 0001:03:00.0
[131009830210] |c0000000-c000ffff : tg3
[131009830220] |ffe04500-ffe04507 : serial
[131009830230] |ffe04600-ffe04607 : serial
[131009830240] |ffe07000-ffe07fff : spi
[131009830250] |ffe24000-ffe24fff : ethernet
[131009830260] |ffe24520-ffe2453f : mdio
[131009830270] |ffe25000-ffe25fff : ethernet
[131009840010] |/home/me/folder/script.sh
, and this script will access the file /home/me/folder/myfile
.
[131009840040] |As the file is in the same path of the script, I just use the name myfile
, not the full path.
[131009840050] |But if I run it from /tmp/
, like:
[131009840060] |it gives me:
[131009840070] |So, how can I say in the script that the file is in the same path as the script itself?
[131009850010] |How about $(dirname "$0")/myfile
?
[131009860010] |You can't know in all circumstances, but often (not always) when you run a script by path instead of letting the shell search $PATH
, the path to the script will be in $0
.
[131009860020] |You can then use dirname "$0"
or ${0%/*}
to get the path.
[131009870010] |I would normally do something like this at the head of my script:
[131009870020] |Or, to get the full pathname to the script's directory (instead of a relative pathname):
[131009870030] |Then just reference ${SCRIPTDIR}
where needed.
[131009880010] |fish://
or sftp://
URLs into Dolphin's Location Bar, or you can use the "Add Network Folder" wizard.
[131009900040] |SFTP at least seems to be supported by Gnome too.
[131009900050] |I personally use Fish.
[131009900060] |On the server machine Fish and SFTP need only an SSH server running, that you can also use to administrate the server machine.
[131009900070] |Everyone who wants to access the server over Fish or SFTP needs a user account on the server.
[131009900080] |The usual file access permissions apply, for files accessed over the network.
[131009900090] |Fish and SFTP are roughly equivalent to shared directories on Windows, but both work over the Internet too.
[131009900100] |Usual (command line) programs however can't see the remote files, only programs that use the file access libraries of either Gnome or KDE can see them.
[131009900110] |To access the remote files through scripts, KDE has the kioclient
program.
[131009900120] |-
[131009900130] |For a setup with a central server that serves both user identities and files look at NIS and NFS.
[131009900140] |Both are quite easy to set up, especially with the graphical installers from Opensuse.
[131009900150] |This is the setup where every user can work at any machine and find his/her personal environment.
[131009900160] |However the client machines become unusable when they can't access the server.
[131009900170] |Furthermore a simple NFS installation has very big security holes.
[131009900180] |The local computers, where the users sit, have to handle the access rights.
[131009900190] |The NFS server trusts any computer that has the right IP address.
[131009900200] |A smart 12 year old kid with a laptop can get access to every file, by replacing one of the local machines with the laptop and recreating the NFS client setup (which is easy).
[131009900210] |Edit:
[131009900220] |Off course there is Samba, which has already been mentioned by Grokus.
[131009900230] |It seems to be quite universal: It can serve files, printers, and login information.
[131009900240] |It is compatible with Windows and Linux; there is really a PAM Module (Winbind) that lets Linux use the login information form a Samba or Windows server.
[131009900250] |Samba (and Windows) does not have the security problems of NFS, it handles user identification and access rights in the server.
[131009900260] |(Please note: I did never administrate or install a Samba server.)
[131009900270] |My conclusion: Fish or SFTP are IMHO best for usage at home.
[131009900280] |Use Samba if you have Windows clients too.
[131009900290] |NFS is only useful if you can trust everybody, but I expect it to create the lowest CPU load.
[131009910010] |If you also want access when you're away from home, I would consider using Dropbox or Ubuntu One for synchronized off-site storage and skip having your own server.
[131009920010] |An of out of the box option is to re-purpose your current boxes as terminals (using something like ThinStation) and set them all up to auto log into a beefy new Ubuntu box.
[131009920020] |You could use DynDNS to keep an external name resolving and access the same system from work (assuming you aren't in a proxy black hole).
[131009920030] |That would keep all of your files in a single location, and let you all share the same environment.
[131009920040] |That said, this is not for the faint of heart.
[131009920050] |Exposing your Linux server to the outside world is somewhat risky.
[131009920060] |You would also all be using the same box, so if it failed you would all be out of luck.
[131009930010] |A central server to host network shares is a good idea, a simple rsync script can ensure certain files stay synchronized on your local PC, if needed.
[131009930020] |The server can also double as a backup location for your important documents, which in turn get backed-up by the server onto an external or online.
[131009930030] |I haven't used this, but Amahi Home Server could be a good place to look.
[131009940010] |update-initramfs
(from initramfs-tools package).
[131009950040] |/etc/initramfs-tools/modules
before running update-initrams
.root=/dev/nfs nfsroot=x.x.x.x:/exportedfs dhcp
in your pxe config's APPEND line./tmp
can simply be a tmpfs.
[131009950090] |For /var
there's a couple of options.
[131009950100] |/var/run
, /var/log
/var/tmp
etc./var
.
[131009950120] |This way, the system will be able to write or change any file under /var
but it won't be persistent./etc/
as well, you'll need a script that will run early in the boot process and setup some per client stuff, like getting the hostname based on the ip and recreating /etc/hosts
and /etc/hostname
.
[131009950140] |/home
folder should also be nfs exported and mounted rw.
[131009950150] |NIS or LDAP or AD or something similar to manage user accounts (and/or configuration files), will help you keep the mess a bit.top
utility doesn't show anything.
[131009960040] |I imagine some daemon which would gather info and log it, so when the slowdown pass away I would be able to find what was the problem.
[131009970010] |The slowdown might not have been caused by CPUs being utilized.
[131009970020] |Check iotop
for IO utilization.
[131009980010] |How about sar?
[131009990010] |Consider installing munin.
[131009990020] |It will monitor a wide variety of data and provide graphical output.
[131009990030] |This is better for monitoring trends.
[131009990040] |You may also want to consider run sar in the background.
[131009990050] |It can identify a number of issues including CPU, I/O, swap, and other issues.
[131009990060] |If you are experiencing problems, this may be your best for your current situation.
[131010000010] |There are a lot of them.
[131010000020] |If you want it to be basic and command-line, take a loot to sar
.
[131010000030] |Or you could use some monitoring tool with nice web ui.
[131010000040] |Personally I prefer zabbix, there are also monitorix (very simple to setup), nagios, zenoss and many others.
[131010000050] |Monitorix is probably what you want on this point.
[131010010010] |sudo
, which Ubuntu embraces, still counts as using root privileges).
[131010020030] |There is no "you shouldn't use root", just "you shouldn't use root for normal tasks".
[131010020040] |For software development you should definitely create a user account for your own and use that for everyday tasks.
[131010020050] |Set yourself up as a sudoer, and disable the root password if you like.
[131010020060] |You probably have to use root access to set up your development environment, so be prepared to go sudo apt-get install thingy
.
[131010020070] |Final words, use root when you have to, but don't feel bad about it.
[131010020080] |It actually feels quite good :)
[131010030010] |wine-alsa
and wine-oss
sound drivers.
[131010030030] |I am able to hear test sounds by running winecfg
, but when I run the webex player there is no sound, and the option to increase volume is disabled.
[131010030040] |I am not sure whether the problem is with wine or with webex; how can I debug/fix this?
[131010040010] |.screenrc
from a friend to start with which put me where I'm at, but I'd like to customize it to afford me this option.
[131010050010] |I turn off the status bar, myself, because that's not a pratical way to manage screen with 40+ windows.
[131010050020] |Using Ctrl-A + " will open a list of all screens.
[131010050030] |You can name individual windows with Ctrl-A + A.
[131010050040] |I also use a customized .screenrc that, among other things, shows the Shell Title message in the Window listing.
[131010060010] |-f -
(i.e. the -
only makes sense in conjunction with -f
) tells tar
to use the standard input/output instead of a filename.
[131010080020] |Which makes sense since you try to pipe the output to ssh
.
[131010080030] |Furthermore, tar
allows writing shorthand options without the leading dash, which is why you (correctly) simply wrote tar f -
instead of tar -f
.
[131010090010] |The "-" is a placeholder for stdout.
[131010090020] |In this case you are piping the output from the one command into the ssh session. the ssh out is piped to the remote server terminal's stdout and is again delivered to the tar command for processing.
[131010100010] |grub.conf
file, usually located in /etc
or /boot/grub
:
[131010170020] |You can say vga=ask
instead to get a menu on boot, built from a probing process performed by the kernel to see which resolutions are likely to work.
[131010170030] |I find that there are often other numbers that will work that this method doesn't find.
[131010170040] |This is all system-specific.
[131010170050] |Different video cards will have different supported modes, and kernel build options can open up or close off video mode options.
[131010170060] |The subsystem that deals with this is called the kernel framebuffer, so if you're compiling custom kernels, be careful not to remove the support your kernel needs to fully support your video card.
[131010170070] |Most cards can use the VESA FB driver, but another driver specific to your brand of card might open more options.
[131010170080] |Also, beware that some parts of this subsystem use hex numbers, and others decimal.
[131010170090] |You can do the conversion to decimal, as I've done, or you can say something like "vga=0x318" instead.
[131010180010] |encfs -i MINUTES
) (where activity means open files).
[131010210120] |It's a good idea to use this if there's a risk that the computer will be physically stolen (mostly relevant for laptops).
[131010210130] |Otherwise there is only a small gain, because most attack vectors let the attacker do worse things anyway.
[131010220010] |libgio.so
?
[131010330020] |On most Linux distributions, there's an automatic way of retrieving the source code of a package.
[131010330030] |For example, on Debian, Ubuntu and derived distributions, run dpkg -S
to see what package libgio.so
belongs to, then apt-get source
to get the source code of that package.
[131010330040] |Example ($
represents my shell prompt; on my system, the gio library is in a file called libgio-2.0.so
):
[131010340010] |ps xf
[131010360030] |In htop
, it shows up like:
[131010360040] |Why does htop show more process than ps?
[131010370010] |For me, on a more-or-less current arch linux system, ps xf
shows me only the processes owned by my user ID. htop
shows me all processes.
[131010370020] |Try ps -ef
for a list of all processes, or perhaps ps -ejH
to get a child/parent relationship listing.
[131010380010] |By default, htop
lists each thread of a process separately, while ps
doesn't. Turn off the display of threads: in the “Setup / Display options” menu, “Hide userlands threads”.
[131010380020] |This puts the following line in your ~/.htoprc
(you can alternatively put it there manually):
[131010380030] |(Also hide_kernel_threads=1
, but it's 1 by default.)
[131010390010] |nohup
.
[131010400030] |This stops the remote machine from terminating the command when you disconnect&
.
[131010400050] |This isn't strictly necessary, but will return you to a shell instead of blocking on the command so you can disconnect normally or do other thingscommand
:
[131010410010] |nohup
is definitely the right way to go if you can run your program without interacting with it: if it writes all its output and error messages into a file that you can get to later, for instance. check the nohup.out
file to see any error messages the program left behind while running (thanks for the correction, Michael!)
[131010410020] |If you need to interact with the program while it's running, GNU Screen might be the better way to go about it.
[131010410030] |It lets you create a virtual terminal which remains running even after you log out, along with any programs you started in it, as long as nobody shuts the computer down.
[131010410040] |Here's a tutorial I found on using it.
[131010420010] |If it is something that needs to happen at regularly scheduled intervals use cron
( e.g. you need to check the website once every hour, or once every day, or more or less frequently than that but still not arbitrarily defined).
[131010420020] |However...
[131010420030] |You may want to run a command at a cerain later time rather than right now, for that you want to use the at
daemon, which allows you to run a command once at a later date/time (like it's 5 o'clock and you want to go home but you've got a 4 hour process that would be best run in the middle of the night, and it's not reoccurring).
[131010420040] |I will say nohup
, screen
, tmux
have been mentioned, use nohup
if you want to run it right now but don't want to reconnnect to that session to check on it later. screen
/tmux
are for checking on it later.
[131010430010] |ln
?
[131010440010] |If you create a relative path to a symbolic link, it will store it as a relative symbolic link, not absolute like your example shows.
[131010440020] |This is generally a good thing.
[131010440030] |Absolute symbolic links don't work when the filesystem is mounted elsewhere.
[131010440040] |The reason your example doesn't work is that it's relative to the parent directory if the symbolic link and not where ln is run.
[131010450010] |You could try:
[131010450020] |But, it makes a symbolic link to the absolute pathname.
[131010450030] |Your textual question asks mentions relative pathname...
[131010450040] |Normally, a relative pathname is what you want, and what ln -s
gives you.
[131010450050] |I think what you want is:
[131010460010] |Sorry, no. Symbolic links are relative to the location the link is in, not the location you were when you created the link.
[131010460020] |There are several good reasons for this behavior, most of which involve mounting remote filesystems.