Tag Info

New answers tagged

0

Yes, you can "connect", but you will be required to change your password, at least on Ubuntu distributions. Some servers will behave differently. debug1: Authentications that can continue: publickey,password debug3: start over, passed a different list publickey,password debug3: preferred ...


0

It happens because somewhat the atom package is not in the path. This could be due to several reasons depending on your Python installation method. This quick workaround worked for me... Just add this two lines... import sys sys.path.append('/usr/local/lib/python2.7/site-packages/') ...on top of this duplicity's gdocsbackend.py file: ...


0

Directly answering the specific questions you posed: Is there a performance penalty during the aggregation/compression/decompression stages for using tar encapsulated in gzip or bzip2, when compared to using a file format that does aggregation and compression in the same data structure? Assume the runtime of the compressor being compared is ...


0

In the category of directly answering the question, there is the ES shell which is intended as a functional replacement for Bash and Zsh etc. Secondly, in the category of helping you right more functional standard shell, consider learning the pipemill technique: who | while read username do cat <<EOF | grep $username nic mark norman keith EOF done ...


-2

If you would like a compile-able program for whatever reason, the following would work: #include <iostream> #include <string> #include <chrono> int timer(seconds count) { auto t1 = high_resolution_clock::now(); auto t2 = t1+count; while ( t2 > high_resolution_clock::now()) { std::cout << "Seconds Left:" << ...


0

There was an issue with your computer connecting to the server on port 63307, possibly a firewall somewhere. Either ensure that all ports > 1024 on the server are accessible, or ensure that the client is not behind a router and all ports on the client are accessible (not firewalled) and use active mode (if supported by the server). This link might provide ...


2

Personally I've found it best not to touch the Java that is used by the OS. Let it live its own life. I simply install the tar.gz packages from Oracle's Java Download Site into a directory e.g. /java. The downside is that this way I'm not using the packaging mechanism (IPS) but on the other hand it allows me full control and I can have as many JREs or JDKs ...


-3

go to the directory where you have all you files and type. find *.pypm


0

The Lempel-Ziv Algorithm (LZ77 and LZ78) is quite an old one and there is a whole family of similar algos around it. You need to specify which exact algo is used to compress your files. Unless you can't tell me what algo is used to compress your data, it is very hard to tell what linuxbased tool can handle it. The filename extension might be a good point to ...


0

The ps command is your best bet, eg. ps u$pidno will tell you virtual process size and resident-set size.


1

Assume you are using gnu find, you can use -delete option: find . -name test -delete which is easier to remember.


1

Also: md5sum filename | cut -c -32 Which has the benefit of having no quotes or characters needing to be escaped, in case you need to embed that command someplace which might have multiple string interpreters acting on it.


0

if you have nodemon installed, then you can do this: nodemon -w <watch directory> -x "<shell command>" -e ".html" In my case I edit html locally and ship it to my remote server when a file changes. nodemon -w <watch directory> -x "scp filename jaym@jay-remote.com:/var/www" -e ".html"


2

Please use ls - the man page tells you how to order the directory. ls -clt | head -n 2 The -n 2 is so you dont get the "total" in the output. If you only want the name of the file. ls -t | head -n 1 And if you need the list in the normal order (getting the newest file) ls -tr | head -n 1 Much easier than using find, much faster, and more robust - ...


0

FYI: Mac OS X does not support the --remove-destination flag so I wrote a simple script to put in your /usr/bin directory: FILE=$1 TEMP=$1".tmp" mv $FILE $TEMP if [ -e $TEMP ] then cp "$(readlink $TEMP)" $FILE if [ -f $FILE ] then rm $TEMP else echo "unln failed." fi fi This one let's you use wildcards: for FILE in ...


0

The find is a real requirement? I'm thinking something like ls -1d /home/*/www/xpto | awk -F/ '{print "chown",$3":development",$0}' (I'm assuming that your usernames are the same of the home folder names.) With the above code you will get the commands you can then run with xargs or in a temporary script.


0

On a linux machine you can use tc with Netem. For instance, the command tc qdisc add dev eth0 root netem delay 100ms will delay all outgoing packets by 100 milliseconds. To delay incoming packets you can use the ifb - Intermediate Functional Block


1

I've seen a pretty neat trick at commandlinefu: use /dev/urandom as a source of randomness (it is a good source), and then using that as a password to an AES stream cipher. I can't tell you with 100% sure, but I do believe that if you change the parameters (i.e. use way more than just 128 bytes from /dev/urandom), it is at least close enough to a ...


0

Brock's Blog describes how you can do that with Ubuntu: Edit /etc/default/grub, adding “delayacct” as an option to the GRUB_CMDLINE_LINUX_DEFAULT entry. If you hadn’t already modified that line, it would go from GRUB_CMDLINE_LINUX_DEFAULT="" to GRUB_CMDLINE_LINUX_DEFAULT="delayacct" Run “sudo update-grub” Reboot, and you should be good to go


1

The simple, stupid answer: You can shorten your sequence of commands a little by combining the first n–1 of them: setfacl -m u:colleague:x /rather /rather/long /rather/long/path /rather/long/path/to /rather/long/path/to/the setfacl -m u:colleague:xr /rather/long/path/to/the/directory An “obvious” warning: Even if you own the target (leaf) directory, ...


0

you can create a group for the users and than you set the file permissions to User rwx Group r-- Other --- so all users have the full permissions, the groupmembers can read and all other have no rights http://support.apple.com/kb/HT2963


1

You want a special file in Linux, /dev/random serves as a random number generator on a Linux system. /dev/random will eventually block unless your system has a lot of activity, /dev/urandom in non-blocking. We don't want blocking when we're creating our files so we use /dev/urandom. try this command: dd if=/dev/urandom bs=1024 count=1000000 of=file_1GB ...


4

There is a random number generator program sharand, it writes random bytes to a file. (The program was originally called sharnd, with one letter a less ( see http://mattmahoney.net/dc/) It takes roughly one third of the time compared to reading /dev/urandom It's a secure RNG - there are faster, but not secure RNG, but that's not what's needed normally. ...


1

for one directory, open a command-prompt window, cd to the desired folder and for %f in (*.txt) do UNIX2DOS %f ... or for all subdirectories use the /R option for /R %f in (*.txt) do UNIX2DOS %f ... It may be worth remembering that, unlike notepad, editors like wordpad and notepad++ are happy with LF as line endings. If you are converting a bunch of ...


0

If you are wanting to get the cpu% programmatically, you may be better getting the information directly from /proc/stat This is discussed at http://stackoverflow.com/questions/3017162/how-to-get-total-cpu-usage-in-linux-c And is also documented at http://www.linuxhowtos.org/System/procstat.htm Hope this helps


6

Use the -u (--unbuffered) option of sed, so it writes it's output, instead of collecting it first for a fast, large write later. cat fifo | sed -u 's/a/b/' | sed -u 's/b/c/' cat is always unbuffered. If it's not about sed, but some program with output buffering, but without options to disable it, there are tools that can help to force buffering off - see ...


1

I couldn't find anything already out there so I wrote a python script to do this (this is probably buggy): #!/usr/bin/env python26 """Add latency to a tcp connection""" from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from functools import partial from twisted.internet.reactor import ( listenTCP, connectTCP, callLater, run ) from ...


0

I don't know why you're looking at the first 496 bytes, since the Master Boot Record (MBR) has always been 512 bytes in size and is located in sector 0 (first sector) of the storage device. What the MBR does is tell your OS about the partition structure of your storage device, and it additionally also contains executable code (the bootloader) that instructs ...


0

Yes, it matters. Tar is an archiver. It just archives gzipp'ed files. Zip is both an archiver and compressor. If you compare compression, from my experience, gzip is much better than zip. And the other significant difference is mentioned in another answer. If you have a very big file archive, and want to extract a small file, Zip allows you to do that. ...


0

DIR /OG /O-D /B - the most recent folder will be listed first.


1

A solution without piping somewhere else would be to pass the directory name to a subshell in find's exec function. This will not be as efficient, and of course it'll try to remove directories that don't exist if they've already been deleted. find . -depth -type f -name 'things.txt' -exec sh -c 'rm -rf "$(dirname $0)"' {} \; If you want to use xargs, ...


0

This has been tested on Linux as these commands below are also executable on Unix system. find -type f -name 'things.txt' | xargs dirname | xargs rm -r Explanation: find -type f -name 'things.txt' --> search for file named 'things.txt' (file only, not directory) | --> piping the result to next command xargs dirname | --> grabbing the directory name the ...


0

I gave up on trying to figure this one out and made one script (~/.shell-setup) which I source from all of the others. This approach requires ~/.shell-setup to have two features: Only run once, even when sourced repeatedly (use Include guards) Don't generate any unwanted output (detect when output is ok) #1 is pretty standard, although maybe not used ...


0

This is a script solution. Lists just the names, no inode data, alphabetical, not case sensitive, formatted into columns. Although it's row-major instead of column major like the default output of ls. The columns get a little messy if there is a file name with >26 characters. rm -f /tmp/lsout ls -1p | grep / | sort -f >> /tmp/lsout ls -1p | grep ...


0

According to your comment you "HAVE TO match against the last line", so I would consider using the $ (last line) and i (insert command) in sed. For example: sed '$ i\INSERT BEFORE LAST LINE' number.txt 1 2 3 4 INSERT BEFORE LAST LINE 5 Just make sure that the file doesn't have an empty line as the last line and it should work. Note the the space between ...


6

Have a look at this excellent blog post by ShreevatsaR. Here's an extract, but go to the blog post, it includes an explanation for terms like "login shell", a flow chart, and a similar table for Zsh. For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C, etc. The B1, B2, B3 means it executes only the first of those ...


15

Over the last few years, I've had a lot of time to waste, so I have researched this for a bit more than just 10 minutes. I have no idea if this is the best layout, it's just one that happens to work correctly in pretty much all cases. The requirements: ~/.profile must be compatible with any /bin/sh – this includes bash, dash, ksh, whatever else a ...


62

TL;DR: ~/.bash_profile should be super-simple and just load .profile and .bashrc (in that order) ~/.profile has the stuff NOT specifically related to bash, such as environment variables (PATH and friends) ~/.bashrc has anything you'd want at an interactive command line. Command prompt, EDITOR variable, bash aliases for my use A few other notes: ...


1

Put everything in .bashrc and then source .bashrc from .profile From the bash man page (on OS X 10.9): When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute ...


9

I offer you my "comprehensive" guidelines: Make .bash_profile and .profile load .bashrc if it exists, using e.g. [ -r $HOME/.bashrc ] && source $HOME/.bashrc Put everything else in .bashrc. Stop worrying. Every four years or so, spend ten minutes researching this very question before giving up and going back to "not worrying". EDIT: Added ...


0

If I am understanding correctly you have a VPS now, in a cloud somewhere, and you have VmWare on your local system, and you want an Ubuntu virtual machine ( guest) running on your VMware that is like your VPS? If so, figure out what version is in your VPS, and use whatever tools VMWare provides to create an instance of Ubuntu with the same version. Or, I am ...


0

I had faced with the same problem, before I found a recipe: put the following text into the file ~/.local/share/mc/bashrc : #!/bin/bash if [ -f $HOME/.bashrc ]; then . $HOME/.bashrc else if [ -f /etc/bashrc ]; then . /etc/bashrc fi fi if [ -z "$PS1" ]; then PS1="(mc)[\u@\h \W]\$ " else old_PS1=$PS1 ...


1

The simplest way to make the message stop without replacing the disk is to force the disk to either mark the sectors as good or bad instead of "maybe possibly bad", which is what "pending" means. You can do this by forcing a full read of the disk: sudo dd if=/dev/sdb of=/dev/null bs=64K conv=noerror This will read every sector of the disk and ignore ...


1

What the other answers are telling you trying to tell you is to use sed’s first~step address form: Addresses …    The following address types are supported:   … first~step Match every step’th line starting with line first.  For example,  “sed -n 1~2p”  will print all the odd-numbered lines in the input stream, and the address  ...


1

sed -f <(sed -e 's/.*/2~2{&;}/' replace.sed) InputFile


0

As pointed out by @Tyson, the PATH variable holds the answer. I just wanted to point out that using full paths in your scripts is usually considered a good practice. For example, instead of calling wc you might want to call /usr/bin/wc. Besides resolving the above problem, it's more secure, as you prevent running an application that someone might have ...


0

Just use sed to make replacements to all HTML files in the current directory: sed -i s/code1/code2/g *.html Or, if you also need to make the replacement to HTML files in subdirectories: find -name '*.html' -exec sed -i s/code1/code2/g '{}' \;


1

Use process substitution to adapt the sed commands in your file on the fly: $ cat replace.sed s#foo#bar# . $ printf "foo\nfoo\nfoo\nfoo\n" | sed -f replace.sed bar bar bar bar . $ printf "foo\nfoo\nfoo\nfoo\n" | sed -f <(sed 's#^#2~2#g' replace.sed) foo bar foo bar


0

Those are separate commands you need to enter separately: chmod a+x file_name.bin ./file_name.bin The first changes the permission on file_name.bin to make it executable, the second runs that program. Entering them as one command just causes the file permissions to be changed twice as both file_name.bin and ./file_name.bin would be used as arguments to ...



Top 50 recent answers are included