create account

Five Linux tips to save you time! by themarkymark

View this thread on: hive.blogpeakd.comecency.com
· @themarkymark ·
$13.40
Five Linux tips to save you time!
![image.png](https://ipfs.busy.org/ipfs/Qmdt62SsqgHDpvwHbkWQ6f4Dk25rUFxfdQd7rcJ7tSZjMG)
# <center>  Five Linux tips to save you time!  </center> #

#### What will I learn?

Below you will find five time-saving tips for navigating the Linux operating system more efficiently.

#### Requirements

You are expected to have some experience using Linux.  

#### Difficulty

Basic

# Let's go!

# 1) History Expansion

While `history expansion` can easily be its own article, I am going to show a few examples.

#### Run the last command that started with...

Say you used the command `vim .bashrc` and then did a few other things.  If you know that was the last file you edited, you can type `!vim` to execute the last command that started with `vim`.

#### Forget to use sudo?

How many times have you tried to run a command that required escalation but you forgot to use `sudo`?   Probably not as often as you should, because you are likely using root (shame on you!).

`apt update`

```
Reading package lists... Done
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
```

Oops, this is where `!!` comes in handy, it will allow you to prefix your last command run.   

`sudo !!` will be replaced with `sudo apt get`

#### Execute the last command that *contains* a string

Similar to the `!vim` command, there is also a search command if you just want to run something that contained a string but did not have to start with it.

`vim /etc/nginx/nginx.conf`<br/>
`!?nginx` will execute the following command again:

`vim /etc/nginx/nginx.conf`

These exclamation point commands will save you a lot of time while using Linux.

# 2) Kill a process by name

Most everyone is familiar with the ability to kill a process by **pid**.  Did you know you can kill a process by name using `killall`?

Is a process hung or you want to abort it?  Without using `ps` to find its *pid* you can use the following command to kill all instances of a process and it's child processes.

`killall mysql`

You can also use `SIGKILL` which is more successful for stubborn processes.

`killall -SIGKILL mysql`

# 3) Reset your terminal

This one is easy but is super helpful.  Have you ever used a curses program that exits and leaves your terminal all funky looking?  You likely just exit SSH and reconnect when this happens right?

Well now you will know to just type `reset` and your terminal will be as good as new.  

# 4) Aliases

I love this trick, do you have a command you type often but it is a syntactical nightmare or you just want a shortcut?

In your `.bashrc` file, you can specify aliases that will be available to you when you are logged in.

The syntax is `alias [alias name]='[command]'`

Some good examples.

`alias untar='tar -zxvf '`
`alias wget='wget -c '`
`alias ls='ls --color=auto'`

and my favorite

`alias yolo='git commit -am "DEAL WITH IT" && git push -f origin master'`

These can be big time savers but they also can cause you to forget the real syntax of commands you use often.  Keep that in mind and review them from time to time.

# 5) Get suggestions and tips for your shell scripts.

This is an amazing tip, there is a tool called `shellcheck` by Koalaman that will lint your shell scripts and give you feedback on how you can clean them up.  If you are particularly weak at creating shell scripts, this will be your best friend.

##### Install shellcheck
`sudo apt update && sudo apt install shellcheck`

Once installed, all you need to do is type `shellcheck <your script>` and it will analyze your script and give you suggestions on how to clean it up.  It will detect portability issues, beginner mistakes, style issues, data errors, and more.

<center>![image.png](https://ipfs.busy.org/ipfs/QmXZpb12QyXSBmTcPUmbjcvq2FXiF2aKYTxg9PPFymwCry)</center>
<sub>[Source](https://github.com/koalaman/shellcheck/blob/master/doc/terminal.png)</sub>

If you don't write shell scripts all day, this tool will become your best friend when the time comes to write one.

Hopefully, you found these helpful and they will save you some time.  Let me know if you want to see more Linux tips or my previous Python Tips series.


πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 152 others
properties (23)
authorthemarkymark
permlinkfive-linux-tips-to-save-you-time
categoryutopian-io
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["utopian-io","tutorials","linux","linuxadmin","busy"],"users":[],"links":["https://github.com/koalaman/shellcheck/blob/master/doc/terminal.png"],"image":["https://ipfs.busy.org/ipfs/Qmdt62SsqgHDpvwHbkWQ6f4Dk25rUFxfdQd7rcJ7tSZjMG","https://ipfs.busy.org/ipfs/QmXZpb12QyXSBmTcPUmbjcvq2FXiF2aKYTxg9PPFymwCry"]}
created2018-11-18 15:41:45
last_update2018-11-18 15:41:45
depth0
children13
last_payout2018-11-25 15:41:45
cashout_time1969-12-31 23:59:59
total_payout_value10.288 HBD
curator_payout_value3.107 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,520
author_reputation1,772,918,693,450,156
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,502,890
net_rshares21,526,392,946,671
author_curate_reward""
vote details (216)
@emrebeyler ·
Good suggestions.

> 2) Kill a process by name

I use pkill for that.
properties (22)
authoremrebeyler
permlinkre-themarkymark-five-linux-tips-to-save-you-time-20181118t155309391z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-18 15:53:42
last_update2018-11-18 15:53:42
depth1
children3
last_payout2018-11-25 15:53:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length69
author_reputation448,528,959,341,273
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,503,544
net_rshares0
@themarkymark · (edited)
`killall` is a bit safer than pkill because it will require an exact match of process name and has a few more options.
πŸ‘  ,
properties (23)
authorthemarkymark
permlinkre-emrebeyler-re-themarkymark-five-linux-tips-to-save-you-time-20181118t161406249z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-18 16:14:03
last_update2018-11-18 16:14:30
depth2
children2
last_payout2018-11-25 16:14:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length118
author_reputation1,772,918,693,450,156
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,504,573
net_rshares678,562,152
author_curate_reward""
vote details (2)
@meno ·
i was about to ask this question... because i also use pkill... hahahah
properties (22)
authormeno
permlinkre-themarkymark-re-emrebeyler-re-themarkymark-five-linux-tips-to-save-you-time-20181118t164901633z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-18 16:49:00
last_update2018-11-18 16:49:00
depth3
children1
last_payout2018-11-25 16:49:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length71
author_reputation506,019,210,353,854
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,506,251
net_rshares0
@grzesiekb ·
I think this is advices for advanced. There is no help for untar "man untar" and etc ..
properties (22)
authorgrzesiekb
permlinkre-themarkymark-five-linux-tips-to-save-you-time-20181118t181353246z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-18 19:13:54
last_update2018-11-18 19:13:54
depth1
children1
last_payout2018-11-25 19:13:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length87
author_reputation2,800,305,353,550
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,513,027
net_rshares0
@themarkymark ·
untar is not a command, it is an alias being created to represent the tar function.  You can find more information about tar by looking at β€œman tar”
πŸ‘  ,
properties (23)
authorthemarkymark
permlinkre-grzesiekb-re-themarkymark-five-linux-tips-to-save-you-time-20181118t200853691z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-18 20:08:54
last_update2018-11-18 20:08:54
depth2
children0
last_payout2018-11-25 20:08:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length148
author_reputation1,772,918,693,450,156
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,515,244
net_rshares784,026,942
author_curate_reward""
vote details (2)
@lovenfreedom ·
Thanks a lot! This one's bookmarked now.

I especially liked history expansion (starts with and contains). I can't count how many times I run a command and it needs to be run with sudo. Although I just use the arrow up key to go through the command history and type sudo if need be. But this is a time saver for sure so I don't have to go through all my history and wear out the ink on the arrow up key.

Next favorite is the alias for convenience and so appreciate the warning :)

πŸ‘  
properties (23)
authorlovenfreedom
permlinkre-themarkymark-five-linux-tips-to-save-you-time-20181118t182018449z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"steempeak","app":"steempeak"}
created2018-11-18 18:20:30
last_update2018-11-18 18:20:30
depth1
children0
last_payout2018-11-25 18:20:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length482
author_reputation25,335,591,446,309
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,510,586
net_rshares533,434,366
author_curate_reward""
vote details (1)
@luegenbaron ·
Damn, I have definetely not enough experience for these tips.
Favorited your article to read him again in some time :)

Posted using [Partiko Android](https://steemit.com/@partiko-android)
properties (22)
authorluegenbaron
permlinkluegenbaron-re-themarkymark-five-linux-tips-to-save-you-time-20181118t154843211z
categoryutopian-io
json_metadata{"app":"partiko"}
created2018-11-18 15:48:42
last_update2018-11-18 15:48:42
depth1
children0
last_payout2018-11-25 15:48:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length188
author_reputation27,465,249,085,978
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,503,274
net_rshares0
@portugalcoin ·
$5.97
Thank you for your contribution @themarkymark.
After analyzing your tutorial we suggest the following points:

- We suggest you make your tutorial more detailed. Explaining a little theory for users to perceive perfectly, especially the most basic users.

Thank you for your work in developing this tutorial.

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/8/21433324).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , ,
properties (23)
authorportugalcoin
permlinkre-themarkymark-five-linux-tips-to-save-you-time-20181118t211337608z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["themarkymark"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/8/21433324","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-11-18 21:13:36
last_update2018-11-18 21:13:36
depth1
children1
last_payout2018-11-25 21:13:36
cashout_time1969-12-31 23:59:59
total_payout_value4.514 HBD
curator_payout_value1.453 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length800
author_reputation598,828,312,571,988
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,517,714
net_rshares9,541,562,615,953
author_curate_reward""
vote details (9)
@utopian-io ·
Thank you for your review, @portugalcoin! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-themarkymark-five-linux-tips-to-save-you-time-20181118t211337608z-20181121t021819z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-21 02:18:21
last_update2018-11-21 02:18:21
depth2
children0
last_payout2018-11-28 02:18:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length64
author_reputation152,955,367,999,756
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,650,131
net_rshares0
@prlndra ·
Posts like these are awesome to see. And it reminds me that I've gotten a bit lax in my knowledge base and experience building. Lately, I do just what I need to at work and focus on expanding that information base where I can. But I've let me experience that I got from useful classes at school lapse. I guess I'll have to come up with a way to correct that issue.

This is some great info, thank you!
properties (22)
authorprlndra
permlinkre-themarkymark-five-linux-tips-to-save-you-time-20181119t163338744z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-11-19 16:33:36
last_update2018-11-19 16:33:36
depth1
children0
last_payout2018-11-26 16:33:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length401
author_reputation131,224,886,868
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,564,861
net_rshares0
@steem-ua ·
#### Hi @themarkymark!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-five-linux-tips-to-save-you-time-20181118t212003z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-18 21:20:03
last_update2018-11-18 21:20:03
depth1
children0
last_payout2018-11-25 21:20:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length291
author_reputation23,214,230,978,060
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,517,951
net_rshares0
@utopian-io ·
Hey, @themarkymark!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-five-linux-tips-to-save-you-time-20181118t235740z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-18 23:57:42
last_update2018-11-18 23:57:42
depth1
children0
last_payout2018-11-25 23:57:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length594
author_reputation152,955,367,999,756
root_title"Five Linux tips to save you time!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id75,523,765
net_rshares0