Hot answers tagged

25

There is pushd and popd: pushd /home/thina/teams/td/tech/app/release/apks # current directory now /home/thina/teams/td/tech/app/release/apks popd # current directory now what it was before pushd command Try help pushd and help popd for more options. There is no man page, because pushd and popd are bash built-in commands.


12

In addition to the very good answers already provided, here are some tips on using cd effectively. cd - will take you back to the last directory you were in. cd ../../.. will take you up 3 levels at once, you can use the .. notation chained together to 'move up' as many directories as you like. If you're not sure how many times you wish to move up, use cd ....


10

You can do this using the printf action of find to print only the modification times in desired format, and then using sort and uniq: find . -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c -printf '%TY-%Tm-%Td\n' prints the modification time of files in e.g. 2015-05-23 format sort sorts the output and uniq -c does the count by date Example: ~/foobar%...


7

To go up in the tree several levels at a time, I use the following function: up () { if [[ $1 > 1 ]]; then local my_path=".." for i in `seq $(($1-1))`; do my_path+="/.." done echo "cd'ing into $my_path" cd $my_path else cd .. fi } Then you can do: $ pwd /home/thina/teams/td/tech/...


7

Using sed: sed 's/[^[:alpha:]]/_/g; s/[[:upper:]]/\L&/g' file.txt This is actually two sed commands separated by ;: s/[^[:alpha:]]/_/g transforms each non-alphabetic character into a _ s/[[:upper:]]/\L&/g converts all uppercase characters into lowercases Example: $ cat file.txt fooBAr132323 SpamEgg $ sed 's/[^[:alpha:]]/_/g; s/[[:upper:]]/\...


7

You want to create a .desktop file. This can be done manually as described here. Alternatively, it should be enough for most applications to run them and then right-click on their launcher icon. The appearing context menu should offer an option Lock to launcher or Add to Dash or similar. Chose that and Ubuntu will try to automatically create an ...


6

First of all, never edit /etc/sudoers manually, always use visudo. Your problem was a syntax error in the file /etc/sudoers.d/90-cloudimg-ubuntu but it is now a malformed /etc/sudoers. So, to fix it (now that you have removed any changes you may have made), run pkexec visudo and make the file look like this: # # This file MUST be edited with the 'visudo' ...


5

For long directory names, use variables with full path. For example, APKS="/home/thina/teams/td/tech/app/release/apks" Then you can do just cd "$APKS" As for going up x number of directories, I have this function defined in my .bashrc goup() # go up x number of dirs { num=$1 while [ $num -ne 0 ];do cd .. num=$( expr $num - 1 ) done } ...


5

Well as I guessed you formatted the Hard drive as FAT, which in fact does not allow you file sizes above 4 GB, so either you chop up the data you want to archive, or format it to something more suitable. If you not need to access this HDD on a Windows machine you could simply go for formatting the drive as ext4 (Linux format). Gparted allows you to do this ...


4

l is an alias for ls -CF the -F option for ls gives file type; the / means the file is a directory. the -C option for ls arranges output in columns For more options to ls see man ls To see all aliases defined in the system just type alias Some default aliases relating to ls (notice that ls itself is an alias!) alias l='ls -CF' alias la='ls -A' alias ll=...


4

There already exists command apt-cache dumpavail which will list all available packages from all enabled repositories. Behind the scenes it actually reads from files stored in /var/lib/apt/lists/ directory (I've done strace of the command, and that's what the output shows) . My guess would be that Gnome Software parses those very same files and organizes ...


4

export PATH=$PATH:~/.config/composer/vendor/bin works for the current session only. In ~/.profile and ~/.bashrc the ~/ doesn't get works within quotes, Either omit the quotes or use $HOME instead of ~/, e.g. export PATH=$PATH:$HOME/.config/composer/vendor/bin /etc/environment doesn't allow any shell syntax so neither ~/ nor $HOME works. Instead you need to ...


3

Here's a solution with find + awk find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val] }' Essentially what happens is that we find all regular files and print their modification time as specified by the %T format , and then awk takes over , and counts each line using associate arrays . ...


3

This solves the first half of your question, but I'm not sure about the second half, or if the second half is simply there to help to solve the first half. Try installing the run script to /usr/local/bin, like this: cd to directory where Android Studio is installed sudo install studio.sh /usr/local/bin/studio Then you can run it with studio from any ...


3

Check the contents of /etc/apt/sources.list.d/canonical-partners.list if they as well exist in /etc/apt/sources.list. If yes remove either the double lines in /etc/apt/sources.list or your remove that canonical-partner.list file. Second might be an easier solution. sudo rm /etc/apt/sources.list.d/canonical_partner.list


3

The graphical desktop view (I assume you mean nautilus, the file viewer) does not always refresh immediately. Press F5 to refresh manually. You may also want to experiment with the fs.inotify.max_user_watches settings as explained in this question. The default is 8192, you can easily raise that to 1000000. inotify is the mechanism that is triggered ...


3

What you want is to type CTRL+L instead of clear. This will send a "Form Feed" to the terminal. Basically it will move everything up the height of the terminal window clearing the screen without affecting your scrollback.


2

White noise is mathematically an even distribution of frequencies. You can produce it with random data from /dev/random or /dev/urandom. If you want to change the "tone" of the produced noise (for example to make it less "weighty" by removing lower frequencies, or to make it "damper" by removing higher frequencies) then you could use a command such as dd bs=...


2

Replace sudo with gksudo -- in your script, like this: gksudo -- sh -c "sync; echo 3 > /proc/sys/vm/drop_caches" That will open a simple dialogue window to ask for your password instead of prompting you for it on STDERR which is not connected to a terminal if you run the script from your desktop. On newer releases of Ubuntu, gksudo might not be ...


2

It's horribly ugly, and not a software center by any means, but if you just want to search for software and see ratings or reviews, try the w3m browser on https://apps.ubuntu.com. Install w3m and w3m-img (for image support): sudo apt install w3m w3m-img Nautilus: lynx-cur: The package name is given beneath the description, so you can then do sudo ...


2

It looks like you want to remove everything before the last | character. However, your second example has a | after the ID and before the hypothetical protein. Presumably, in that case, you want to remove everything before the last | that is not followed by a space. Here's one way: $ sed 's/| / /; s/^[^ ]*|/>/' file.pep >CAX10446 conserved ...


2

You need to have the full directory in the /etc/environment for the PATH statement. /home/username/.config/composer/vendor/bin After the changes made, you need to reboot the host so that the changes in /etc/environment can take effect. Hope this helps!


2

Try sudo tar acvf /home/john/Desktop/KS_UserFolders.tar.gz \ --exclude='*.m4v' \ --exclude='*.m4a' \ --exclude='*.mp3' media/john/OS/Users/ Note that the archive file name must come right after the f option (without a -), and the --exclude options need two dashes.


1

UPDATE: There's an even more powerful tool than autojump: fasd, but I am not familiar with it. I am surprised no one has mentioned autojump yet which works by maintaining a database of the directories you use the most from the command line (Directories must be visited first before they can be jumped to.) It's basically what @graipher has built, ...


1

As I already answered on a related question on UnixSE, I use a script called z [github] for this. It remembers directories you cd to, ranks them according to frecency (frequency + recency) and allows you to change to one of the remembered paths using some part of its name. After having cd'ed to a directory at least once you can do e.g instead of: $ cd ~...


1

Three more options that I find to work well (though I may in the future use pushd more, I only just learned about that): Arrange your paths so you don't need to cd into deeply nested directories in the first place, or rather: so the locations that you need to visit often are right at your fingertips. The way to achieve this is with symlinks: keep the ...


1

Have you given the file the permissions to execute? sudo chmod +x studio.sh or maybe you can try: sh studio.sh I have installed Android Studio last year and it all went fine, if this doesn't solve your problem, comment that I'll try to see other solutions :)


1

Not really one single command, but why make it more complicated than necessary? find -type f -name ".*" -delete; rm *~ The first command removes all files starting with . and the second one all ending with ~


1

Bash makes a difference between single quotes '...' and double quotes "...". Single quotes cause the enclosed text to be taken literally while double quotes allow various interpretations of the string like variable expansion. You must use double quotes if you have $x-like Bash variables in your string which you want to be expanded. Additionally, directly ...


1

You are out of luck when attempting to rename .torrent files with aria2c, from the man pages: -o, --out=<FILE> The file name of the downloaded file. When the --force-sequential option is used, this option is ignored. NOTE: You cannot specify a file name for Metalink or BitTorrent downloads. Note that this ...



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