New answers tagged command-line
0
votes
Screenshot using the terminal command
In recent versions, the gnome-screenshot tool remains available for installation in current Ubuntu versions. It works correctly with Wayland.
0
votes
Terminal not opening on Ubuntu 22.04 on Virtual box 7.0.0
This worked for my Virtualbox 7.0 with host Windows 10 and guest Ubuntu 22.04.
Start Virtualbox machine and press Shift quickly until the grub boot menu is shown.
Go to Advanced options for Ubuntu ...
0
votes
How do I make Ctrl-arrow skip over dots and dashes
You can try the following actions:
shell-forward-word (M-C-f)
Move forward to the end of the next word. Words are delimited by non-quoted shell metacharacters.
shell-backward-word (M-C-b)
Move back ...
1
vote
Screenshot using the terminal command
"In all ubuntu versions" is the tricky part here. In older releases you could use gnome-screenshot to do this. But more recent releases of Ubuntu don't have that binary, as the screenshot ...
0
votes
How can I quit when connected via telnet?
For me I've tried holding Control and tried everything from 1 to 0.
I found out that Control+5 worked for me. It took me back to the main telnet prompt and from here you can leave like @Oli mentioned ...
0
votes
How to remove special 'M-BM-' character with sed
A easy solution was offered in https://stackoverflow.com/a/36371440/906489 by Jens
tr -d '\200-\377' m.txt > m-no-8bit.txt
That removes all values from 128 to 255, which is octal 200 to 377 (which ...
1
vote
How to get gzip operating recursively at all depths?
Not an exact answer to your question, but you can use xargs for that, which allows you to run multiple gzip processes in parallel, like
find -name '*.vtk' -print0 | xargs -r0n1 -P$(nproc) gzip
look ...
2
votes
How to get gzip operating recursively at all depths?
After the answer by terdon, and upon tinkering a bit, I came to the conclusion that the way -r works is the following:
If what is matched is a file (only in the present directory) do gzip.
If what is ...
8
votes
Accepted
How to get gzip operating recursively at all depths?
No, gzip can't do this, -r just means "descend into subdirectories" but there is no option for "descend into subdirectories and then look for files matching this glob". The ...
0
votes
wget to download files from list of urls and naming it from other list of names
You can use this script:
#!/bin/bash
# URLs.txt
# NAMEs.txt
count=1
while read URL; do
NAME=$(sed "${count}q;d" NAMEs.txt)
wget -O $NAME $URL
count=$((count+1))
done <URLs.txt
0
votes
Accepted
Running an app under specific locale "formats"
Is there a way to run an app under specific locale and formats (en_US
and en_GB respectively) for testing purposes, without affecting
system-wise settings?
Yes, you can set environment variables on ...
2
votes
Accepted
Scheduled a computer to reboot everyday at 7AM, not sure if I did it correctly
Your, cronjob and logic is correct syntax-wise and you can verify if you succeeded in installing the new crontab for your user with:
crontab -l
... and you should see your added cronjob listed in the ...
0
votes
Open Microsoft Edge in Ubuntu
Assuming that you install the .deb package from https://www.microsoft.com/en-us/edge, you can use the following command the start MS Edge directly and load the page you want:
$ /opt/microsoft/msedge/...
0
votes
Accepted
caret character unexpected behaviour in regular expressions with grep
My intention is to find the keywords starting with "zip"
The caret ^ matches the beginning of a line and not the beginning of a word ... Therefore, grep '^zip' dirlist*.txt will only match ...
1
vote
Accepted
changing grep command --color from red to another color
The simple solution:
Add --color=always to the grep options... then pipe the result into
| sed -re 's/31m/32m/' and you will get green text instead of the red.
Another way is described in the man page:...
0
votes
RPM Euro Games keyboard backlight not working in ubuntu 20.04
Hey if you are still facing the issue try running the below command in you terminal, it worked for me.
sudo xmodmap -e 'add mod3 = Scroll_Lock
0
votes
Open Microsoft Edge in Ubuntu
The Edge browser from windows is not the one you use in Ubuntu. Download the DEB, install it through software center and it will be available as a suggested browser.
0
votes
How to write a bash script from two commands (Find and replace a text string in all files recursively in current directory)
This site is not a script-writing site, but help to anyone on planet Earth is a strong motive in this community (no discrimination against beings from other planets :-) thogh).
That said, take the ...
0
votes
Accepted
Intermittent lag in command terminal?
welcome to the forum.
System Resources
This seems like a hunt to find which system resource is insufficient but we can't tell because there is not enough information. You could provide details like:
...
2
votes
Accepted
I followed a solution procedure on AskUbuntu, logged out and now all my data is gone (no guest account)
Problem
User home directory and everything in it were deleted
Explanation:
The command rm -rf ~ performs the following actions:
rm: This is the command used to remove files or directories in Unix-...
2
votes
Accepted
What are zsh equivalent to bash's shopt -s globstar and shopt -s dotglob?
Recursive globbing is the default in zsh, it doesn't need to be enabled. The ** glob is simply syntactic sugar here:
A pathname component of the form ‘(foo/)#’ matches a path consisting
of zero or ...
1
vote
Copy a folder name into the name of its files
In a Bash shell loop with mv:
for f in */*; do
if [ "${f%/*}" != "Pictures" ]; then
echo mv -nv -- "$f" "Pictures/${f%/*}${f#*/}"
fi
done
You'll ...
0
votes
Accepted
Invoke a program as a command on any working directory on ubuntu's terminal
Copy your program into your $HOME/bin directory. Next login your $PATH should contain your bin dir, so the program should work as you described.
3
votes
Copy a folder name into the name of its files
If both directories are located in the same parent directory, in Desktop as an example, you can use something like:
cd ~/Desktop
rename -n 's,^(.*)/,Pictures/$1-,' Mexico/*.jpg Spain/*.jpg
Note that ...
0
votes
Copy a folder name into the name of its files
The following script should work.
for file in $(find "./$1" -type f);
do
cp $file "./Pictures/$1$(basename $file)"
done
It goes through the files in the $1 (argument 1) ...
1
vote
Changing Linux file names to NTFS-compatible file names
With Perl's rename:
rename -n 'y/\\: /__\-/ if -f' *
... where -n is for a dry-run (to actually rename files, remove it or change it to -v for verbosity), y will translate each character in the ...
0
votes
Changing Linux file names to NTFS-compatible file names
Create a script, e.g. translate.sh:
#! /bin/bash
old=$1
new=${1//:/_} # Replace colons by underscores.
new=${new// /-} # Replace spaces by dashes.
new=${new//\\/_} # Replace backslashes by ...
0
votes
Switching Plasma theme from the command line
kwriteconfig5 seems to be an actual answer. But there is no documentation on the Internet.
For example, to switch to the default Breeze theme the command is:
kwriteconfig5 --file kdeglobals --group ...
2
votes
How to stop wget command?
Kill the wget command by using pkill, and sending the TERM signal (default for the command):
pkill -x wget
If this doesn't work, send the KILL signal instead:
pkill -9 -x wget
0
votes
How to exit gpick color picker after picking from a keyboard shortcut?
To pick single color and output use:
gpick --pick --single --output
or:
gpick -pso
0
votes
Accepted
Database not saving imported sql file in terminal MySQL
It turns out the sql file that I imported had a USE query.
I was just supposed to use the database that were set in the sql file, or delete the USE query in said sql file.
Thank you @glenn jackmann ...
0
votes
How do I select a field/column from the output of `ls -l`?
I need to catalog my installed applications prior to backing up and upgrading and encountered this issue trying to figure out how to trim ls output, but the awk applications suggested in other Ask ...
-1
votes
Home directory not being created
My issue was that SELinux was preventing creation of home directory upon login by an unprivileged user:
$ ls -ldZ /home/
drwxr-xr-x. root root system_u:object_r:root_t:s0 /home/
That root_t was ...
3
votes
How to fix "chmod" permissions after running "chmod 222 /bin/chmod"?
You can execute a file that lacks execute permission simply by calling its interpreter. Here's a very simple example:
$ touch file
$ stat -c '%a' file
664
$ echo 'echo hello' > file
$ ./file
bash: ....
4
votes
Cut folder names out of string
Oh okay, here is a sed answer
$ echo 'TRUE|/home/linux/test|(null)|' | sed -r 's#.*/([^|]+)\|.*#\1#'
test
Explanation:
-r use extended regex
s#...#..# find and replace using # as an alternative ...
0
votes
Not able to update or upgrade after upgrading from Python 3.10.12 to Python 3.11
You can try using re-installing the gnome-terminal.
First, you'd like to take a back of the gnome setting if you configured it well. Here - https://askubuntu.com/a/1056392/1774643
Second, re-install ...
3
votes
Cut folder names out of string
It's not really clear from your question if you want to get the third item of an absolute path or if you want to get the last item of an absolute path.
If you want to get the third item of an ...
11
votes
Cut folder names out of string
There are already two working solutions here, but I just wanted to also point out the following method, which maybe maps onto the imperative mindset more.
echo 'TRUE|/home/linux/test|(null)|' | awk -F ...
13
votes
Cut folder names out of string
Bash has a very easy way to match elements of a path (as long as your path is defined as a variable) with parameter expansion.
Using the ${parameter##word} construct, you search from the beginning of ...
0
votes
accidentally moved almost all my files in a new directory, is it the end for me?
The mv command doesn't keep a record of file movements, and the metadata of the moved files will not contain a history of last locations.
I think your best option now will be to write some scripts to ...
8
votes
Accepted
Cut folder names out of string
If you would like to get "Extra credit" for your assignment, Then use awk
echo 'TRUE|/home/linux/test|(null)|' | awk -F '[|/]' '{print $5}'
The awk option -F defines the field separator(s). ...
0
votes
Login for Terminal
On my side, it's revesed. Ctrl + Alt + F1 turns me back to graphical session. Ctrl + Alt + F3 takes me to the terminal session.
0
votes
How do I determine the total size of a directory (folder) from the command line?
One can use 7z (sudo apt-get install p7zip-full) to determine the total apparent size of a directory from the command line. Example:
7z -mx=0 a temp16584.zip /path/to/directory
It will show the total ...
2
votes
How to fix unresponsive Terminal
‘.bashrc’ is executed when you start a Terminal session so, yes, that is a probable cause. You’ve likely added something in there which is not finishing and the Terminal session is waiting for it to ...
0
votes
How do I rerun the second-to-last command?
On top of using Ctrl-R <term> or !-2 to re-run an old command, you can also view your command history and run it by index as well. Say your history looks like:
...
1770 ls
1771 ...
0
votes
How do I open Ubuntu Software Center via Terminal?
For Ubuntu 22.04.3 use the command
snap-store
In case it does not load try this:
killall snap-store
sudo snap refresh
source: Ubuntu software does not load in Ubuntu 22.04.3 LTS
1
vote
Bash script using eyeD3 to remove extra tags from mp3 files
The error is from mawk, which is the default implementation of awk in Ubuntu. Sometime between Ubuntu 18.04 and Ubuntu 20.04, this was fixed so that mawk would work fine with the FS as give ():):
% ...
0
votes
Arrow keys, Home, End, tab-complete keys not working in shell
I believe it depends on the terminal and the environment the terminal operates in. There are various issue sources which may affect the case.
However, in Konsole terminal connected through SSH to a ...
0
votes
How to completely restart script from inside the script itself
Late & noob, but I had to use absolute path to make mine work:
exec "/usr/local/bin/audio-device-switch.sh"
(exec "$ScriptLoc" didn't work for me)
0
votes
Accepted
Custom alias to run and compile .c file
I don't think you can include a variable within an alias. And in any case, you cannot use a variable within single quotes, you'd have to use doublequotes instead.
This function should work. Place ...
Top 50 recent answers are included
Related Tags
command-line × 22929bash × 5413
scripts × 2738
gnome-terminal × 867
text-processing × 862
permissions × 714
server × 703
apt × 673
ssh × 565
14.04 × 543
sudo × 511
software-installation × 492
python × 488
files × 486
16.04 × 450
gnome × 443
networking × 428
directory × 417
grep × 366
18.04 × 361
shortcut-keys × 357
12.04 × 355
sed × 351
package-management × 336
find × 327