The commands which make life in cyberspace easier
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
alpcentaur ea8c7bf74d trying sub overviews 2 years ago
README.md trying sub overviews 2 years ago

README.md

Table of Contents

  1. Important Linux commands
  1. The package manager(s)
  2. Getting some INFO about the system
  3. Cool programs you find on almost all linux

Important Linux commands

The commands which make life in cyberspace easier.

In the shell, you have to imagine the jumps. Because the computer will only be projecting code in your mind from your mind.

You are a specific point on some system, when you are in the shell. you can see what is in the directory you are with the command

ls

this command also can display other useful information. Of what is inside the directory you are in.

cd

The most important one. Instead to click, you change directories via command. that makes it possible to jump from one point to the other, especially with autocompletion.

man

In general you can get the manual entries for each of the programs described here and much more.

Just type

man cd

or type man ls

and you will get the manual opened historically with nano or less.. not sure, both good old editors.

cp

copy files from one place to another. (relatively from you)

cp /dirA/file1.py /dirB/file1.py

when there is already file1.py in the destination directory, it gets overwritten.

Concept of piping with >

in the shell you have standard input and standard output. Nothing more. to pipe the standard output from one program into a file, you write it like this:

ls > file.txt

When you write like that, youll overwrite everything in the file with the output.

If you want to append to a file what a program has as standard output, you can use >> instead. Writing it like this:

ls >> file.txt

This both is piping. There is another very important aspect of piping described later.

mkdir

another basic command. Create a new directory ("make dir")

su

stands for super user. use it to become super user. then the symbol in your shell changes from $ which means you are normal user to # which is the sysmbol of being superuser, or in other words: root.

sudo

this is a program you can put in front of commands, to get the superuser for only this command, typing your password of course. then for other x times writing sudo, you can issue commands as superuser without even typing in a password.

alias

give your complicated commands easy remember commands. Or build the own language of your shell.

alias cls=clear

This sets up an alias called cls. It will be another name for clear. When you type cls, it will clear the screen just as though you had typed clear.

On my Arch Linux, I can write these aliases in my bashrc config file. I need to issue the command

source bash_profile

to get the configuration loaded. On other linux there will be an analogon.

cat

print out what you have in front of you on the standard output.

also print several together

for instance:

cat doc1.txt doc2.txt > doc1ANDdoc2.txt

chown

On linux everything are only directories and (txt)files. All these objects have an owner, or also multiple ones.

sudo chown -R root /ole/ola/kp.txt

gives root the ownership of kp.txt

chmod

Every owner then has file permissions. That means he can read write or x (do) something. he can do all of them or some of them or none of them. Thats defined in codes, 777 gives them all and 660 doesnt completely.

sudo chmod 777 ole/oi/file.txt

bzw

sudo chmod 660 ole/oi/file.txt

Just look it up what people say regarding permissions and certain directories.

history

this lists all the commands of the shell you are in, that you have typed in lastly.

grep

if you have some bigger output of some of the former commands for example. Or whatever big output. then use grep to filter out the lines that have a certain word in it. GRAB it.

grep -lr word

is pretty cool. It searches you all the files recursively from your point in cyberspace - if they have in that "word". If yes, than the command will print out the file.

piping with |

here comes into account the piping with |.

Directly combining it with the history command is pretty effective..

history | grep "whatsoevercommandIalreadyfiguredoutbutreallydontwanttosearchoutagain"

here the output of history gets piped into the program grep. as the output of history gives one command per line, grep will filter out exactly the command in which the pattern "whatsoever" occur.

the package manager(s)

One of the biggest differences between different operating systems is their package manager. Or better, the different programs for managing installations, removal etc of all software. For a software, to get into the collection of a certain OS, can be more or less difficult. In Arch Linux for instance, you will find some of the latest stuff. On other systems, like trisquel linux, you wont find closed source stuff. The package manager is the software which talks to these package collections.

debian linux based apt

APT stands for Advanced Packaging tool.

If I want to install a package, first I look in the so called "mirrors" of my system. What versions are available? What further tools, connected with the software I wanted to install, are also available? For debian, an option is to use

apt-cache search "library"

then, to install the package, usually

apt-get install "lib"

is used.

If you want to make some install breaking out of the system philosophy, sometimes you want to issue

dpkg install "lib"

The tool apt is build from dpkg. But if u use dpkg, you should know what youre doing.

If you get into conflicts, which means you have massively a lot of software and a new install breaks dependencies (this shouldn't happen, but it did to me), then

aptitude install "lib"

is cool. It gives you different scenarios, listed in pretty complex manner, and you can choose what way to go. Choosing what software should break, which not, or maybe there is even a solution enabling everything you want to run at the same time.

When you remove packages, with apt you have the possibility to either remove or purge the code. The one is deleting everything, the other is deleting the software but leaving configurations etc. Such that in case youll get the software again, you can kind of start from the point you were. But sometimes Everythings broken because of broken configurations. Then deleting everything can make everything running again.

Arch linux based pacman

On Arch linux, pacman does a lot for you.

To install, you use

pacman -S "lib"

To remove, you use

pacman -R "lib"

To search for packages, you use

pacman -Ss "lib"

To search in the user repository, and to install the stuff you can find there (stuff not quite on the same level as on the arch system repo, but sometimes prototypes and unstable but nice stuff) you can use

pacaur -Ss "lib"

or the other commands. Here most pacman commands work, the difference is you use pacaur without sudo.

getting some info about the system

df

prints you out disc usage of your hardware

df -h

does it in humanreadable

du

prints out the size of files around you

du -h -d 2

prints in human readable with depth 2, that means in the directories and in their subdirectories.

lsblk

prints you out all the hardware devices with memory

lscpu

prints you out info about the central processing unit

lspci

prints out lots of hardware, everything that is connected with pci, which means the fast stuff

lsusb

prints out everything connected with usb. More than everything, prints you also nice codes in the format 666:666 which is a wonderful help for finding drivers for usb connected devices.

htop respectively top

gives you a terminal graphics programm interface to see all running processes

tail -f

with tail or also head, you can print out the last or the first lines of a file

When you use tail -f, you get a stream of the documents last lines.

Thats perfect for some log files that get written.

journalctl -f

this gives you a stream of the kernel messages, which are pretty a lot about a lot of different topics of the programs on your machine.

The kernel is the ground software, running the hardware of the proper materia device. Its mostly in C. C is like the base of all languages. (if its not assembly)

uname (-a or -r or other)

gives you general infos about system, OS, and stuff

systemctl

some people do not like systemctl. I personally have parts of my structures that are managed by this software. with

sudo systemctl status nginx.service

I ask systemctl to give me the status of the nginx daemon, running in the background of my (and actually all of my machines there is running one nginx daemon) machine.

cool programs you find on almost all linux

ssh

with ssh, the secure shell, you can be on other computers worldwide connected to the internet. its basically the same thing as getting the standard shell programm of the system running the ssh daemon. but almost all systems do that as a standard

scp

thats copying from one computer to the other with the ssh protocol

rsync

better than scp because it can easily recover when something bad happens during the up or download of something big. from its syntax ssh alike.

vnc

is like ssh but for video

torify

the freedom of the internet is not a joke. with torify you can tunnel other programs over tor. with tor, with systemctl status/start/stop tor.service, with reading and writing the torrc (THE configuration file of tor) you can easily host a knot point or a bridge. Just understanding a lot about tor is already helping a lot for our freedom.

ncat

on linux OSes, or probably also on other computers, a lot of things are organised in so called ports.

ssh has port 22 http has port 80 https has port 443

a lot of these ports have different programs that use them. already over knowing these ports and their programs, you get to know GROUND computer stuff. OLD computer stuff. pretty strong stuff all coders kinda agreed and agree on.

with ncat, ports arent a problem anymore. just pip any port on any port (in the end, ports are also only directories, because there are only dirs and files on UNIX (kinda linux and apple together)).