linux commands handbook (pdf), Study notes of Design

All those commands work on Linux, macOS, WSL, and anywhere you have a UNIX environment. I hope the contents of this book will help you achieve.

Typology: Study notes

2021/2022
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 09/12/2022

maya-yct
maya-yct šŸ‡¬šŸ‡§

4.8

(9)

217 documents

1 / 135

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64
Discount

On special offer

Partial preview of the text

Download linux commands handbook (pdf) and more Study notes Design in PDF only on Docsity!

Table of Contents

Preface

Introduction to Linux and shells

man

ls

cd

pwd

mkdir

rmdir

mv

cp

open

touch

find

ln

gzip

gunzip

tar

alias

cat

less

tail

wc

grep

sort

passwd

ping

traceroute

clear

history

export

crontab

uname

env

printenv

Conclusion

Preface

The Linux Commands Handbook follows the 80/ rule: learn in 20% of the time the 80% of a topic.

I find this approach gives a well-rounded overview.

This book does not try to cover everything under the sun related to Linux and its commands. It focuses on the small core commands that you will use the 80% or 90% of the time, trying to simplify the usage of the more complex ones.

All those commands work on Linux, macOS, WSL, and anywhere you have a UNIX environment.

I hope the contents of this book will help you achieve what you want: get comfortable with Linux.

This book is written by Flavio. I publish programming tutorials every day on my website flaviocopes.com.

You can reach me on Twitter @flaviocopes.

Enjoy!

Linux can also be used as your day to day computer. I use macOS because I really enjoy the applications, the design and I also used to be an iOS and Mac apps developer, but before using it I used Linux as my main computer Operating System.

No one can dictate which apps you can run, or "call home" with apps that track you, your position, and more.

Linux is also special because there's not just "one Linux", like it happens on Windows or macOS. Instead, we have distributions.

A "distro" is made by a company or organization and packages the Linux core with additional programs and tooling.

For example you have Debian, Red Hat, and Ubuntu, probably the most popular.

Many, many more exist. You can create your own distribution, too. But most likely you'll use a popular one, one that has lots of users and a community of people around it, so you can do what you need to do without losing too much time reinventing the wheel and figuring out answers to common problems.

Some desktop computers and laptops ship with Linux preinstalled. Or you can install it on your Windows- based computer, or on a Mac.

But you don't need to disrupt your existing computer just to get an idea of how Linux works.

I don't have a Linux computer.

If you use a Mac you need to know that under the hood macOS is a UNIX Operating System, and it shares a lot of the same ideas and software that a GNU/Linux system uses, because GNU/Linux is a free alternative to UNIX.

UNIX is an umbrella term that groups many operating systems used in big corporations and institutions, starting from the 70's

The macOS terminal gives you access to the same exact commands I'll describe in the rest of this handbook.

Microsoft has an official Windows Subsystem for Linux which you can (and should!) install on Windows. This will give you the ability to run Linux in a very easy way on your PC.

But the vast majority of the time you will run a Linux computer in the cloud via a VPS (Virtual Private Server) like DigitalOcean.

A shell is a command interpreter that exposes to the user an interface to work with the underlying operating system.

It allows you to execute operations using text and commands, and it provides users advanced features like being able to create scripts.

This is important: shells let you perform things in a more optimized way than a GUI (Graphical User Interface) could ever possibly let you do. Command line tools can offer many different configuration options without being too complex to use.

man

The first command I want to introduce is a command that will help you understand all the other commands.

Every time I don't know how to use a command, I type man to get the manual:

This is a man (from manual ) page. Man pages are an essential tool to learn, as a developer. They contain so much information that sometimes it's almost too much.

The above screenshot is just 1 of 14 screens of explanation for the ls command.

Most of the times when I'm in need to learn a command quickly I use this site called tldr pages : https://tldr.sh/. It's a command you can install, then you run it like this: tldr , which gives you a very quick overview of a command, with some handy examples of common usage scenarios:

This is not a substitute for man , but a handy tool to avoid losing yourself in the huge amount of information present in a man page. Then you can use the man page to explore all the different options and parameters you can use on a command.

compared to the plain ls , this returns much more information.

You have, from left to right:

the file permissions (and if your system supports ACLs, you get an ACL flag as well) the number of links to that file the owner of the file the group of the file the file size in bytes the file modified datetime the file name

This set of data is generated by the l option. The a option instead also shows the hidden files.

Hidden files are files that start with a dot (. ).

cd

Once you have a folder, you can move into it using the cd command. cd means c hange d irectory. You invoke it specifying a folder to move into. You can specify a folder name, or an entire path.

Example:

mkdir fruits cd fruits

Now you are into the fruits folder.

You can use the .. special path to indicate the parent folder:

cd .. #back to the home folder

The # character indicates the start of the comment, which lasts for the entire line after it's found.

You can use it to form a path:

mkdir fruits mkdir cars cd fruits cd ../cars

There is another special path indicator which is. , and indicates the current folder.

You can also use absolute paths, which start from the root folder / :

pwd

Whenever you feel lost in the filesystem, call the pwd command to know where you are:

pwd

It will print the current folder path.

mkdir

You create folders using the mkdir command:

mkdir fruits

You can create multiple folders with one command:

mkdir dogs cars

You can also create multiple nested folders by adding the -p option:

mkdir -p fruits/apples

Options in UNIX commands commonly take this form. You add them right after the command name, and they change how the command behaves. You can often combine multiple options, too.

You can find which options a command supports by typing man . Try now with man mkdir for example (press the q key to esc the man page). Man pages are the amazing built-in help for UNIX.

mv

Once you have a file, you can move it around using the mv command. You specify the file current path, and its new path:

touch test mv pear new_pear

The pear file is now moved to new_pear. This is how you rename files and folders.

If the last parameter is a folder, the file located at the first parameter path is going to be moved into that folder. In this case, you can specify a list of files and they will all be moved in the folder path identified by the last parameter:

touch pear touch apple mkdir fruits mv pear apple fruits #pear and apple moved to the fr

cp

You can copy a file using the cp command:

touch test cp apple another_apple

To copy folders you need to add the -r option to recursively copy the whole folder contents:

mkdir fruits cp -r fruits cars