LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-16-2019, 01:36 PM   #16
Tux!
Member
 
Registered: May 2011
Location: Netherlands
Distribution: openSUSE
Posts: 114

Rep: Reputation: 32

$ cat /etc/profile.d/local.sh
alias dir="ls -al"
alias ll="ls --color=auto -alio --time-style=+'%Y-%m-%d %H:%M:%S'"
alias l="ls --color=auto -aCF"
alias a=alias
alias et="exec tcsh"

Now, the first command I give when loging in to a user that does not have the correct shell is

$ et

and I can continue as a happy user
 
Old 05-16-2019, 02:00 PM   #17
msargent
LQ Newbie
 
Registered: Jun 2013
Posts: 1

Rep: Reputation: Disabled
teletype

<ctrl>s and <ctrl>q
 
Old 05-16-2019, 02:44 PM   #18
zer0sig
LQ Newbie
 
Registered: Sep 2017
Location: tech capital of the southeast USA
Distribution: CentOS, Fedora, Armbian, RHEL, Kali, MATE
Posts: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by msargent View Post
<ctrl>s and <ctrl>q
I have run into some older, particularly proprietary/industrial type OSes/control systems where there is no more/less/any command to control output flow and this has been useful. Also people who have worked out of terminals for a long time suddenly remember "the good old days" when you do it, heh.
 
1 members found this post helpful.
Old 05-16-2019, 02:50 PM   #19
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,146
Blog Entries: 6

Rep: Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834
Let me see if I can get in a few.

Code:
counter() {
    str=$(printf "%20s")
    sleep_time=20
    while [ "$sleep_time" -gt 0 ]; do
        echo -ne "This computer will self destruct in "$sleep_time" seconds. Press x to reset.\r"
        read -t 1 -s -n 1 key
        if [[ "$key" = [Xx] ]]; then
            sleep_time=20
        fi
        sleep_time=$(($sleep_time - 1))
    done
    echo -e "\n"${str// /BOOM }""
}

counter
 
3 members found this post helpful.
Old 05-16-2019, 03:10 PM   #20
nypaulie
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Rep: Reputation: Disabled
Zapping subtitles

I download lots of MP4 & MKV video files and sometimes they are subtitled so these are the command-lines to zap 'em.
For mkv: mkvmerge --no-subtitles input.mkv -o output.mkv
For mp4: mencoder input.mp4 -ovc copy -oac copy -o output.mp4
 
1 members found this post helpful.
Old 05-16-2019, 03:11 PM   #21
FrenchGuy
LQ Newbie
 
Registered: Oct 2008
Location: Toulouse, France
Distribution: Arch
Posts: 18

Rep: Reputation: 8
zsh ...
 
Old 05-16-2019, 03:21 PM   #22
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Rep: Reputation: 220Reputation: 220Reputation: 220
Apart from some readline keybindings such as C-a, C-k, C-e, C-u, C-y, M-y, C-w etc. that really not many people use in practice I like dabbrev-expand feature of xterm:

Quote:
dabbrev-expand()

Expands the word before cursor by searching in the preceding
text on the screen and in the scrollback buffer for words
starting with that abbreviation. By default bound to Meta /.
Repeating dabbrev-expand() several times in sequence searches
for an alternative expansion by looking farther back. Lack of
more matches is signaled by a beep(). Attempts to expand an
empty word (i.e., when cursor is preceded by a space) yield
successively all previous words. Consecutive identical expan-
sions are ignored. The word here is defined as a sequence of
non-whitespace characters. This feature partially emulates the
behavior of `dynamic abbreviation' expansion in Emacs (also
bound there to M-/).
I have this in my ~/.Xresources:

Code:
UXTerm*VT100.Translations: #override \n\
     Meta <Key>/:dabbrev-expand() \n\
I use it daily, for example after running
Code:
udisks --mount /dev/sdc1
something like that this is shown:
Code:
Mounted /org/freedesktop/UDisks/devices/sdc1 at /media/757f2f53-f46a-4a28-90a7-f36ae106071b_
Now to go to /media/757f2f53-f46a-4a28-90a7-f36ae106071b_ I just type /m and pres M-/ (Alt-/) and the entire '/media/757f2f53-f46a-4a28-90a7-f36ae106071b_' string shows up on the screen. There is no way to do that with pure Bash AFAIK but I heard it might be possible to achieve with ZSH.

Apart from that I enjoy using GNU screen thanks to it copying && pasting and screen recording capabilities.
 
3 members found this post helpful.
Old 05-16-2019, 03:21 PM   #23
nypaulie
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Rep: Reputation: Disabled
These commands can be run from desktop launchers:

Restart Network
sudo service network-manager restart

Reboot
sudo reboot -h now

Shutdown
sudo shutdown -h now

Note: I am a Linux (Mint) user. HATE Windows!
 
Old 05-16-2019, 03:44 PM   #24
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,146
Blog Entries: 6

Rep: Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834
Lets see, how about controlling a mouse from terminal. You'll need xdotool installed.

Example:
Code:
a=('xdotool' 'mousemove_relative' '--' '0' '-15')
b=('xdotool' 'mousemove_relative' '15' '0')
c=('xdotool' 'mousemove_relative' '0' '15')
d=('xdotool' 'mousemove_relative' '--' '-15' '0')

for i in {1..10}; do
    seq 20 | xargs -Iz "${a[@]}"
    seq 20 | xargs -Iz "${b[@]}"
    seq 20 | xargs -Iz "${c[@]}"
    seq 20 | xargs -Iz "${d[@]}"
done

#Mouse clicks if you need them
e=('xdotool' 'click' '1')
f=('xdotool' 'click' '3')
g=('xdotool' 'click' '2')
 
Old 05-16-2019, 04:28 PM   #25
cyent
Member
 
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 398

Rep: Reputation: 87
Scenario... son leaves a couple of hundred tabs open, I want to go to sleep and in the morning I want to briefly use my computer without battling 100's of tabs for a CPU slice.

Answer: Switch to "The Dark Place" , a virtual console (ctrl-alt-f1), log in as root...

killall -STOP --user fred;killall -KILL --user fred;sleep 1;pm-suspend;loguout

Let's break that down...

It borrows a trick from systemd... if you kill a child process the parent may attempt to restart it. But if want them all dead anyway.... stop them all (including the parent), then kill them.

Let the fallout of that settle for a second, then invoke power management suspend which puts the whole desktop to sleep... all the blinkenligte go off.

If anyone wakes it by touching a button, it logs out of root.
 
1 members found this post helpful.
Old 05-16-2019, 04:38 PM   #26
Bill_L
LQ Newbie
 
Registered: May 2019
Location: Southeast Iowa, United States
Distribution: openSuSe Leap 15
Posts: 8

Rep: Reputation: Disabled
As a relative new user again(been over 25 years so since HP-UX and SuSe 3.5) just being able to use terminal commands at all without a lot of head scratching
 
Old 05-16-2019, 04:46 PM   #27
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,737

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
!some_command to re-run a command from history. Can be shortened to the a unique sub-sed of the name. e.g. !so
Ctrl-d to exit from su -- or the terminal if it's the last login
Ctrl-l to clear the screen (learned that one recently here) -- that's an ell, not a one.
 
3 members found this post helpful.
Old 05-16-2019, 04:48 PM   #28
josephj
Member
 
Registered: Nov 2007
Location: Northeastern USA
Distribution: kubuntu
Posts: 214

Rep: Reputation: 112Reputation: 112
Bash history tool

I search bash history using a fuzzy search and put the results in my clipboard using Ctrl+F as a hotkey.

Code:
# fh - repeat history

fh() {
  history | tac | "$HOME/bin/fzf" +s | sed -re 's/ *[0-9]* *//' | awk '{printf "%s", $0}' | xclip -se c
}

## bash code to bind fh to a hotkey
bind '"\C-F":" fh\n"'  # fzf history on ctrl+F
I know bash has some built-in history search features, but I like this better.

It took awhile to figure out how to get it into the clipboard so it could be edited before being run.

This code lives in .bashrc.
 
Old 05-16-2019, 04:51 PM   #29
hastrogirdo
LQ Newbie
 
Registered: Sep 2017
Distribution: Deepin
Posts: 7

Rep: Reputation: Disabled
Organize folders by the Linux terminal

mv *.mp3 /home/paulo/Music
mv *.jpg /home/paulo/Pictures
mv *.mp4 /home/paulo/Videos
mv *.odt /home/paulo/Documents
 
Old 05-16-2019, 04:52 PM   #30
areeda
LQ Newbie
 
Registered: Jun 2012
Posts: 3

Rep: Reputation: Disabled
My favorite, most used trick is also the most trivial and most obvious.

To add a command to your history without executing it just make it a comment by prepending a '#'

Conversely to grab a command from your history to edit append '' eg: $ !501 That silly emoji is ": p" without the space

Last edited by areeda; 05-18-2019 at 10:04 PM. Reason: damn emoji
 
4 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: What is your favorite Linux terminal trick? LXer Syndicated Linux News 0 08-01-2018 12:41 PM
Poll: (Without the poll) - How is Linux used in your workplace? SlowCoder General 13 09-11-2007 11:03 PM
vim :gui trick and undo-trick dazdaz Linux - Software 3 09-10-2007 02:45 PM
Poll: What is your favorite brand of Motherboard? dstrbd1 Linux - Hardware 2 02-16-2006 05:40 PM
Weekly Hardware Poll, Dec 14th: What's your favorite notebook? finegan Linux - Hardware 18 12-03-2004 12:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration