LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 05:33 PM   #31
sanflores
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Rep: Reputation: 2

cp file.txt{,.bkp}

Use ir a LOT
 
2 members found this post helpful.
Old 05-16-2019, 05:37 PM   #32
greencedar
Senior Member
 
Registered: Sep 2018
Distribution: Linux Mint 19.1 Tessa & 19.3 Tricia
Posts: 1,314
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by greencedar View Post
I enjoy:

Code:

~$ sl

Didn't know what you are talking about - not installed by default on my system (Xubuntu something something). Does that count as a "trick"? Because if anything you can install counts as a trick...
Here is the code to install sl:

Code:
sudo apt-get install sl
Hope you enjoy your train ride!
 
1 members found this post helpful.
Old 05-16-2019, 05:43 PM   #33
Crippled
Member
 
Registered: Sep 2015
Distribution: MX Linux 21.3 Xfce
Posts: 595

Rep: Reputation: Disabled
Re: What's your favorite Linux terminal trick?

delete terminal
 
Old 05-16-2019, 08:05 PM   #34
m.a.l.'s pa
Member
 
Registered: Oct 2007
Location: albuquerque
Distribution: Debian, Arch, Kubuntu
Posts: 366

Rep: Reputation: 139Reputation: 139
Ctrl+R ("reverse-i-search"), to pull up previously-used commands from bash history. And pasting selected text into the command line with a middle mouse click.
 
4 members found this post helpful.
Old 05-16-2019, 08:18 PM   #35
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,322
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Customizing .bashrc and .vimrc.

This is a simple one that I use frequently.

Code:
ps -A | grep [string]
 
1 members found this post helpful.
Old 05-16-2019, 08:27 PM   #36
ChuangTzu
Senior Member
 
Registered: May 2015
Location: Where ever needed
Distribution: Slackware/Salix while testing others
Posts: 1,718

Rep: Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857Reputation: 1857
Tab to autocomplete...real time saver
 
1 members found this post helpful.
Old 05-16-2019, 08:33 PM   #37
Nick888
LQ Newbie
 
Registered: May 2019
Posts: 4

Rep: Reputation: Disabled
I have my .bashrc automatically attach to a tmux session, or create one if it doesn't already exist. It basically creates a persistent terminal session. So if I close my terminal emulator, it'll reopen my terminal session when I open a terminal emulator again. It's really useful when configuring window managers, and when you want to switch between window managers without stopping any currently running jobs. I'll post the code for it later.
 
Old 05-16-2019, 08:41 PM   #38
tgbauer
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Rep: Reputation: Disabled
Most useful, especially over ssh, is “screen”
Read the manual and learn basic control keys first
 
Old 05-16-2019, 09:03 PM   #39
tgbauer
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Rep: Reputation: Disabled
This is one for when you wish instead of giving you an error and telling you how to correct it, it would just make the correction for you:
[removed]

Last edited by jeremy; 05-17-2019 at 08:27 AM. Reason: Please read the LQ rules
 
2 members found this post helpful.
Old 05-16-2019, 09:34 PM   #40
FabricMan
LQ Newbie
 
Registered: Apr 2019
Location: Cincinnati OH USA
Distribution: Ubuntu 20.04 LTS
Posts: 4

Rep: Reputation: Disabled
I know this is super basic, but piping program output to grep. The day I learned I wouldn't have to wade through a twenty-thousand-line log file in a text editor felt like winning the lottery!
 
Old 05-16-2019, 09:46 PM   #41
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,322
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Let me add

Code:
CTRL-r [string]
to search for previous commands.
 
5 members found this post helpful.
Old 05-16-2019, 11:08 PM   #42
aveatch
LQ Newbie
 
Registered: Dec 2006
Location: Colorado
Distribution: pclinuxos kde, lxqt
Posts: 3

Rep: Reputation: 1
One that I use often when I want to dump some text in to a new text file quickly.
cat - > test.txt
enter or paste text
CTRL d when done.

use cat - >> test.txt to append the file.

Last edited by aveatch; 05-17-2019 at 01:29 AM. Reason: Wrong case
 
1 members found this post helpful.
Old 05-17-2019, 01:06 AM   #43
yasheshb
LQ Newbie
 
Registered: May 2019
Location: Mumbai, India
Distribution: Fedora Core
Posts: 3

Rep: Reputation: Disabled
sort files and directory by size

Code:
du -sk * | sort -n
 
1 members found this post helpful.
Old 05-17-2019, 01:10 AM   #44
greencedar
Senior Member
 
Registered: Sep 2018
Distribution: Linux Mint 19.1 Tessa & 19.3 Tricia
Posts: 1,314
Blog Entries: 1

Rep: Reputation: 128Reputation: 128
After copying a command that I want in the terminal:
Quote:
Shift + Insert
will automatically paste the text in the terminal.
 
2 members found this post helpful.
Old 05-17-2019, 01:40 AM   #45
Nick888
LQ Newbie
 
Registered: May 2019
Posts: 4

Rep: Reputation: Disabled
Here's the line from my .bashrc

Code:
# don't automatically attach a tmux session if we're
# in a TTY, since I usually like to run startx from
# the command-line, and you can't do that in tmux
if [ ! $( tty | grep "/dev/tty[1-9]" ) ] && \
        [[ $- = *i* ]] && \
        [ ! $( tmux attach-session -t 0 2>/dev/null) ]; then
    tmux 2>/dev/null
fi
Here are some other tips, some of which are pretty basic, but I didn't know about them when I first started.

* If you use vim, then you can enable vi line editor in bash with "set -o vi".
* In man pages, you can search through them by hitting the slash key, entering a regular expressions,
and hitting enter. You can use n and N to search forward or backward through the results of the search.
* If you have a command with a lot of output, just type !! | less. !! just expands to the previously
executed command, and | less just pipes the output of it into less, a pager.
You can search through the output the same way you can when viewing a man page (IIRC, this is because man actually uses less).
* Heredocs. There are lots of tutorials online on how to use them.
* Sometimes if you accidentally display binary output on the terminal, it'll jumble up all the text
and cause the terminal to act weird. You can fix it by using the "reset" command.
 
3 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 09:07 PM.

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