Tag Info

Hot answers tagged

43

Bash only expands a ~ if it's the beginning of a word. You can see this between the following commands: $ echo -extract=~/test -extract=~/test oli@bert:~$ echo -extract ~/test -extract /home/oli/test Bash looks for standalone ~ characters and ~/ for this substitution. No other combination or quoted version will work. $HOME works because variable ...


15

The meaning of the tilde In a shell, ~, the tilde, is not really a path. It is only replaced by a path, $HOME, some times. It is something like a shorthand, or abbreviation, provided by the shell. It can not be used like a path in general, the shell "expands" it to a path only in very special places. And even if it is expanded, it can be to something else ...


12

sh, the Bourne shell, is old. It's behaviour is specified by the POSIX standard. If you want new behaviour, you use bash, which gets new features added to it all the time. On many systems, sh is just bash, and bash turns on a compatibility mode when run under that name. On Ubuntu, sh is dash. The brace expansion is a relatively new feature, and would not be ...


5

This answer is partially a summary of the comments, but here it is: There is no way the code works in IDLE like it is pasted into your question: you do not call the function, and (thus) it has no argument as well. To make it run from the terminal, your code (file) should at least include: def num(b): print("Give a number ") b = b + 5 print(b) ...


4

No it isn't. As you said, man sim doesn't exist. And running sim gives No command 'sim' found, but there are 23 similar ones In your example 'sim' was only used as part of a file name. 'fun-sym' could have been almost anything, it has no effect on the command. Since it is only the file you are creating, it only has to be a valid file name. All that ...


4

If your goal is to execute a one-line command that: Removes and recreates the directory ~/Desktop/foo if it already exists. Just creates the directory ~/Desktop/foo if it does not already exist. Then you can use: rm -r ~/Desktop/foo; mkdir ~/Desktop/foo ; is equivalent to a newline, but it lets you execute multiple commands on a single line (i.e., as ...


3

Your suggestion is incorrect. Convert is available for all users. If you're converting into a PDF and you're seeing Unable to open image 'xxx.pdf', the program has tried to open xxx.pdf for writing and has been rebuffed by the Kernel because the current user can't write to that file. There are a couple of reasons: The current $USER can't write to the ...


3

~ is not a path per se. It's a character that gets special treatment from the shell where ~ or ~/ means "replace with current user's home directory path". ~username means "replace with username's home directory path". Because it's not a path, it's only recognized in certain places in the command (as the first character of a new space-split token). When ...


3

You can get the default arp cache timeout by: cat /proc/sys/net/ipv4/neigh/default/gc_stale_time In my case it's 60. That means 60 seconds until the entry is removed. Every time the entry is used in the table, the timer for this entry resets to 60 seconds. Additionally you can set it by: echo 3600 >/proc/sys/net/ipv4/neigh/default/gc_stale_time Or ...


3

No, there is no single command to do what you are asking. Why? This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together.1 In this instance, the mkdir and rm commands do what you require, and work well together, since rm -r will delete the directory as well, so a subsequent mkdir will create ...


3

SH is stupid. It can not do anything. It only knows the most basic commands. It does not do anything else. It can not understand {1..99} as a numeric value. It understands it as a string. SH/Dash is not developed. It is meant to be an emergency prompt for DIRE circumstances (in interactive mode. Otherwise, it's a really good thing for scripting.). Bash ...


3

You should be able to use unzip's -d option to set an alternate directory for the archive contents. unzip -d a a.zip unzip -d b b.zip and so on. Within a find expression, you should be able to derive the name for the directory from the name of the zipfile using shell parameter expansion e.g. find -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} ...


2

Archive Mounter uses gvfs to mount the ISO images. On 14.04, you'll find it mounted under /run/user/<UID>/gvfs/ Where UID is your username's UID. If you are the only user on the system, this is probably 1000. You can find out your UID by running id. There's an environment variable called XDG_RUNTIME_DIR that should hold the path ...


2

streamer can still do this: streamer -t99999999999999 -r 10 -o output0000000.jpeg The awkward looking -t argument is there to cope with the fact that streamer needs to know how long it's going to be recording for. Still, that's several thousand years. Just Control+C to exit out when you're done recording. The -r argument sets your framerate.


2

UEFI + Ubuntu-14.04.1-desktop-amd64 With a UEFI boot (without CSM enabled in firmware), the media boots into a GRUB menu. UEFI booting can be troublesome, some firmware has the tendency to change from UEFI to BIOS boot in between reboots. Other times the USB stick needs to be plugged in a different port after each boot for the firmware to recognize it. ...


2

The command to remove a directory is rm. So you need 2 commands. rm -r ~/Desktop/foo/ mkdir ~/Desktop/foo/ As shown in comments you can chain them with ; (= do both even if 1st fails) or && (= only mkdir when the rm does not fail). The -r is for removing dirs. The 1st command also removes ALL contents of the directory. If that is NOT your ...


2

If you're just looking to wipe the entire hard drive, you can just run: sudo dd if=/dev/zero of=/dev/sda bs=4M Assuming that sda is is the hard drive you want to wipe. That being said, be careful! This will wipe THE ENTIRE HARD DRIVE, INCLUDING ANY OTHER OPERATING SYSTEMS YOU MAY HAVE INSTALLED. Since you overwrote your windows with debian anyway, you're ...


2

just type this sudo apt-get install program1 program2 program3 in a terminal to install many programs in the same command. Or you can use install scripts. Which are basically .sh files that have these commands in them, example below: sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install htop Put it in a file and name it like script.sh and ...


1

First you how to actually partition your hard drive with the fdisk utility. Linux allows only 4 primary partitions. You can have a much larger number of logical partitions by sub-dividing one of the primary partitions. Only one of the primary partitions can be sub-divided. fdisk is started by typing as root fdisk device at the command prompt. Device ...


1

There are a few options available: fdisk (older, doesn't support GPT4). parted (the CLI brother of GParted). The various mkfs programs, if you already have partitions and wish to format. fdisk and parted are interactive, and have help commands, so you can always look for help within the program. Both are also scriptable. The mkfs commands are not ...


1

I had the same problem but was not very happy with the solutions here or the solutions did not work for me. What I found out to get it running is to send a NULL input to apt-get, so that it continues to work. It looks like this: apt-get -y install gcc g++ make cmake perl < "/dev/null" cd ~/ mkdir t1 cd t1 #newline Hope other people can use this ...


1

In order to get the rtsp and H264 support, you will need to build the application from source. The primary version of the source is at https://github.com/sackmotion. There are however many forks of this source the implement various features including RTSP/H264. If you review the graphs / network tabs in git you can see these versions and determine which ...


1

Use ssh with -X option: ssh -X [user@]hostname teamviewer See man ssh for more info.


1

If found the answer I was looking for just in case someone comes across this in the future. Here's how: dan@micro:~$ ssh bigbox dan@bigbox:~$ export DISPLAY=:0 dan@bigbox:~$ teamviewer TeamViewer popped right up on my big PC. Perfect!


1

You are correct. the ~/Downloads is the same as /home/username/Downloads. Some installers and extractors are just very picky about where it needs to put things. I think it might be because it logs the filepaths, and the logs wont accept ~ in an accepted path. I just got used to typing in /home/username instead. :)


1

I came up with this solution: open ~/.bashrc in an editor copy this and add it at the end of .bashrc file: PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] ' save the file and restart bashrc: source ~/.bashrc For a full list of available colors and further options look up these links: ...


1

A version that is a bit more 'general' - should work with a varied environment: (depends on terminfo) Insert this in your $HOME/.bashrc function fgtab { echo "tput setf/setb - Foreground/Background table" for (( f=0; f<8 ; f++ ));do for (( b=0; b<8 ; b++ ));do echo -en "$(tput setf ${f})$(tput setb ${b}) $f/$b "; done; echo -e ...


1

/etc/environment is not a script file, you cannot use variables, for further reading I recommend https://help.ubuntu.com/community/EnvironmentVariables


1

/etc/environment takes a proper re-login to take effect, because it is processed by PAM at login. Further, as @przemo noted, it is not run or sourced as a script, so variables are not expanded. Put such variables in a .sh file in /etc/profile.d/: sudo tee -a /etc/profile.d/my_vars.sh <<"EOF" export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1 ...


1

Use two percentage characters. [Desktop Entry] Type=Application Terminal=false Icon=vinagre Name=RDP Exec=/usr/bin/rdesktop -g 90%%x90%% SomeHostName Desktop Entry Specification: http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html



Only top voted, non community-wiki answers of a minimum length are eligible