[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

The fact is Linux sucks balls out of the box. That's fine,

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 71
Thread images: 5

File: 1374092499887.jpg (357KB, 608x1100px) Image search: [Google]
1374092499887.jpg
357KB, 608x1100px
The fact is Linux sucks balls out of the box. That's fine, I'm not complaining, but I want to know how to work the terminal and all that to get it running nice and smooth and to my liking. What is the best way? Is there a good series of videos I can watch or a book I can read?
>>
>>45807478
som body put PePes eys on the face
>>
>>45807478
Install GNU + Gentoo Linux
>>
>>45807478
What exacly you want to be able to do?
>>
Install Gentoo, fo real
>>
>>45807478
Install Android x86.
>>
>>45807517

Anything. Nothing in specific I just want to have the skills to do something without looking it up if it occurs to me
>>
>>45807478
Maybe you should do a little more research.
>>
>>45807526
>Android x86
>I was skeptical so I looked it up and it's actually real

Absolutely disgusting, why would you want to run a handicapped mobile OS on an x86 machine?
>>
>>45807532
Huh.

Basics:

invoking a program or shell builtin:
program_name argument argument argument ...


So for example, to launch skype, you type
$ skype
. But without the $. When people prefix commands with a $, they mean "run that normally", so you just copy paste it.

Sometimes people write
# progra, argblah blah blah ...
, that means you must run this as root. Root is an equicalent of Adminiatrator account in the Windows Operating System ...


Shall I continue, or do you want something more advanced?
>>
>>45807604

chris@chris-System-Product-Name ~ $ firefox

(process:13435): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

What does that mean? It opened up firefox but what is this message telling me
>>
>>45807657
Every program has that errors, but they are by default silenced. You don't see them on Windows at all, the OS is not letting you.

I'll continue, but you have to wait because I'm typing this from a phone.
>>
>>45807657
Continuation, you can type, or paste, this all into your terminal. don't type the '$', because it's your
chris@chris-System-Product-Name ~ $
:

$ # If you enter a literal "#", everything to the next newline is considered as a comment, your shell will just ignore it. That's why it is all in one color here on 4chan.
$ # It's good when you are writing shellscripts, you can just comment them for future yourself
$ echo ur a faggot # echo echoes everything in its argument
ur a faggot
$ a="a faggot" # this is a variable. It's simple as fuck see:
$ echo $a
a faggot
$ echo ur $a
ur a faggot

There are a lot of different commands. You can tab-complete their names, example:
$ firef[CLICK TAB HERE]
changes to
$ firefox
>>
>>45807734
You can use some basic stuff do move between directories. In unixes, ~ means your home directory, in this case
/home/chris
. It's equivaled of the Windows' %HOME%, which is \Users\chris or something similar.

If you are new to Limux, don't use \ as directoriy seperator. It's /home/chris, not \home\chris.

~ $ # the ~ indicates where you are
~ $ ls # this command lists files in a current directory. The directories are usually in blue.
gayporn downloads fourchan_images
~ $ # we can get help of any command by typing --help as its argument.
~ $ ls --help
...

# this was too long to paste, ezecute this command yourself.

...
~ $ # we can test some things from that help.
~ $ ls -1
gayporn
downloads
fourchan_images
~ $ # ls -l is sometimes useful, too
~ $ cd downloads
~/downloads $ ls
a.jpg b.gif



Are you still there?
>>
>>45807734
>>45807860
Not OP, but reading this stuff is great. Should I learn bash? Or is it like if I know one shell, I know them all, and I should therefore learn something else?
>>
>>45807951
Bash. Most bash things works in every shell used these days.
>>
>>45807966
Thanks man. I was considering bash because it's just so damn common
>>
>>45807951
>>45807966 (Me)

Cont:

How do you find help?
$ given_command --help
isn't always covering everything. In that situation, you type man.
$ man given_command
. That should open a manpage that provides some more help. If you want to search for a manpage, try apropos or whatis. (Suggestion:
$ apropos --help
).
>>
>>45808008
Cont:

What are really these 'commands'?

Let's check:

$ type ls
ls is /bin/ls


What about...
$ type echo
echo is a shell buildin


There's also the -a option for $ type. It means 'all'. Only the first displayed line is used, but it can sometimes be useful.

$ type -a echo
echo is a shell builtin
echo is /bin/echo


So, /bin directory. Is this the only one with programs, you might ask?
Nope.
$ type firefox
firefox is /usr/bin/firefox


These directories are stored in the $PATH vatiable, seperated by colons.
$ echo $PATH
/bin:/usr/bin/:/usr/local/bin:DO_THIS_URSELF_RESULTS_MAY_VARY_FROM_SYSTEM_TO_SYSTEM

We can also change it - don't worry, opening the terminal again will fix it.
$ PATH=   # we leave it empty, because why not?
$ firefox
bash: command not found: firefox
$ type firefox
firefox not found
>>
This book is good if you are 100% new to the command line.

http://www.amazon.com/Linux-Command-Line-Complete-Introduction/dp/1593273894/ref=sr_1_1?ie=UTF8&qid=1419709278&sr=8-1&keywords=the+linux+command+line
>>
>>45807478
http://linuxcommand.org/tlcl.php
>>
>>45808093
Cont:

Execute this yourself:
$ mv --help

$ cp --help

Those are helpful.


sudo

Sudo works like runas in windows, but is a lot better.
Its name means "super user do" or "switch user do". It's a better version of the old "su".

By default, it runs as root. When you type something like
$ mv /bin /mybin
it will simply not work. You, as a user, can ideally only moify your home directory, your ~.
$ sudo mv /bin /mybin 
should work. But don't try this at home, you will probably have to recover your system, because /bin is a fundamental part of it.
>>
99% of tweaks can be done easiest in the command line. Just understand a few details like $ vs # and you'll be able to follow any guide. Find guides, if one is too complicated find another one. Soon you won't need things dumbed down and you'll just want the straight information - arch wiki is good for this even for other systems. Don't copy and paste (or avoid it at least).

So pick something to change and start googling. When you have problems google that too.

The stuff anon is showing is sort of handy, but I never use any of that. Editing the path is handy and I didn't really understand that until after years of using linux.

Also using some_command -h or man some_command will give you info on it. Easy for quick lookups, but most of the time I just use google.
>>
>>45807478
go fuck yourself
>>
>>45808285

Cont:

Let's say that you have a folder with images, every image is .png, and you want to move them like to things like 1.png, 2.png, 3.png ... N.png.

How would you do that? Asking on 4chan does not count.

Let's write an one-liner.

You cd to that directory, and then type:
$ i=1; for file in *; do mv "$file" $i.png; (( i++ )); done


There are a couple of things to explain here.

I'll continue this.
>>
>>45807478

>I'm a dried up stinky dicklicker. Plz halp me rice up my Leetnix box so it looks like Zero Cool's and I can hack teh Gibsonz.
>>
install crunchbang u fuckin idiot
>>
>ifconfig
For network stuff is really handy, though apparently dated - idk I still like it the best

>iwconfig
also handy for network stuff

>lsblk
Great for finding where drives are located. Each is reffered to as /dev/something usually /dev/sda or /dev/sdb and /dev/sda1 for referring to partitions (should be done even when there's only 1 anyways)

>some_command | grep some_word
The | is called a pipe and it runs the output to grep - which I think of like grab. It'll search and only output relevant stuff

>cat some_textfile.txt
Outputs contents of a text file (hint use this with grep)

>touch some_filename
Will create a file or update the modification time. You can touch a bunch of files at once just list them one after another

>nano some_file
Will edit a file and create one if it doesn't exist. The key bindings are at the bottom of the screen. ^ is equal to ctrl. So ^X is ctrl plus X (as I've taken to calling it).

>mv
This can also rename a file

>rmdir
Will only remove an empty directory

>rm -r
This shit cannot be undone, maybe make your own trash directory and mv things, though I never did this, just be careful

>rsync
Learn this, super handy.
Then tailor the command to your needs and save it in a text file.
Then execute it with ./your_script
You'll first have to
>chmod 755 filename
Learn what it is, but just use chmod 755 to give some file read, write, and execute permissions. There is another way of doing chmod, but it is for homosexuals.

That's all for now.
>>
File: are_you_wizard.jpg (44KB, 600x797px) Image search: [Google]
are_you_wizard.jpg
44KB, 600x797px
>>45808389
>>45807604
>>45807734
>>45807860
>>45808008
>>45808093
>>45808285
>>45808389
>all on a fucking phone
Poor bastard
>>
>>45808389

Cont:


First thing, the ; is equal to entering two command, one after another.

So we could have just typed:
$ i=1
$ for file in *
$ do mv "$file" $i.png
$ (( i++ ))
$ done


So, first, i=1 I think that this says for itself, it sets $i to 1.

Next,
for

For loops usually look like this
$ for some_variable_name in AYYYY L M A O
$ do echo my thing: $some_variab
$ done
my thing: AYYYY
my thing: L
my thing: M
my thing: A
my thing: O


I'll continue
>>
>>45808636
Correcting, not $some_varab, but $some_variable.
>>
>>45808850
Whoops, messed code tags:

>>45808636
Cont:

In bash, type
$ help for
if you don't understand it. Or search the internet. I am not very good at explanating loops.

So,
*
, the "wildcard".

If you are in the directory that has the following files: asd.png, dfasdas.png, something.jpg,
$ echo I have files: *
I have files: asd.png dfasdas.png something.jpg
$ echo All pngs I have: *.png
All pngs I have: asd.png dfasdas.png


In the example, a couple posts above, we could have used "*.png" instead of just "*".
But we knew that there was only png files in that directory, so it doesn't matter.

So, the
for file in *
would turn into
for file in asdasd.png qwertyui.png tfwnogf.png
, depending of what you have in that directory.

Let's say that you have three files: a.png, abc.png and nogf.png.

The for poart would turn into
for file in a.png abc.png nogf.png
.

I'll continue this.
>>
>>45808867

Cont:

next part,
mv


We can know, from
$ mv --help
that mv accepts generally two arguments and stands from "move".

In unixes, renaming is also moving.

So, for example:

~/documents $ ls
a.txt reports.txt
~/documents $ mv a.txt my_report.txt
~/documents $ ls
my_report.txt reports.txt


That's great, but what if the filename had spaces in it?

~/documents $ ls
i have spaces.txt reports.txt
~/documents $ # mv i have spaces.txt new file with spaces.txt # would not work
~/documents $ mv "i have spaces.txt" "new file with spaces.txt"
~/documents $ ls
new file with spaces.txt reports.txt


That's actually the reason why people who use Unixes don't like spaces in filenames.


So, the mv part is
mv "$file" $i.png
is not written
mv $file $i.png
, because it would fail if we have a file with spaces in its name.

I'll continue.
>>
>>45809011
Cont:

(( i++ ))


That part can be confusing.

Just launch bash and type
$ help let
.

It is equivalent to

let i++
# which is equivalent to
let i += 1
# which is equivalent to
let i = i + 1

which is equivalent to english: "take the value of $i, add 1 to it, store it in $i."

I'll continue.
>>
>>45807478
>Linux sucks balls out of the box
What box?
Also you don't need to know anything about the terminal to use the friendlier distros.
>>
File: 1394083486017.jpg (108KB, 833x676px) Image search: [Google]
1394083486017.jpg
108KB, 833x676px
monitoring the thread. I like what you are doing anon.
>>
>>45809074
Cont:

done

It's explained in >>45808636,
for
needs to end with
done
.

So, we now have all parts of this oneliner explained. Let's turn debugging mode on and see how this executes

$ set -x

By the way, this is an useful thing to put in the beggining of a shellscript, if you can't figure out what is going wrong. Or you can run that shellscript via
$ bash -xv scriptname.sh
. Or add it to the end of the first line, if it starts with a "#!". You can disable it with
$ set +x


So, let's see how this works in real bash:

$ ls
abc.png a.png nogf.png
$ set -x # we enable the debug mode to see what is going on. Debug mode messages starts with a "+".
$ i=1; for file in *; do mv "$file" $i.png; (( i++ )); done
+ i=1
+ for file in '*'
+ mv abc.png 1.png
+ (( i++ ))
+ for file in '*'
+ mv a.png 2.png
+ (( i++ ))
+ for file in '*'
+ mv nogf.png 3.png
+ (( i++ ))
$ set +x # we disable the debug mode now, we no longer need it.
$ ls
1.png 2.png 3.png


As you can see, it works like a charm.


Hey anons, give me ideas to script.
>>
>>45809102
like OS X. You get all the *nix goodness with none of this guy.
>>
what are the best resources for learning bash?
>>
Another anon that's also lurking, some great tips here:
>>45807604
>>45807734
>>45807860
>>45808008
>>45808093
>>45808285
>>45808389
>>45808532
>>45808636
>>45808867
>>45809011
>>45809074
>>45809258

Excellent stuff anon, bumping in the hope others might see.
>>
>>45809152
Can I save this for commands in bash, or is it unrelated?
>>
>>45807546
For Dev purposes tard
>>
>>45809332
That's the filesystem in unixes. Type
$ cd /
$ ls
or just $ ls / to see that.
>>
>>45809332
well, it may help you to organize your scripts since the purpose of a specific folder isn't always quite clear. Also it gives you an idea where stuff might be.
>>
>>45809258
Cont:

Filters.

Let's say that you have 30000 lines long logfile, and you were interested in searching for something in it. Let's say, you want to see the Internet Explorer in your Apache web server log. IE's userstring is "Trident" (ask microsoft why).

First,
$ cd /var/log/httpd
, That's Apache's directory for logs.
access_log
is a file where the recent logs are stored. Where are the old ones? Do
$ ls
, you'll see.

$ grep Trident access_log


Yes, it's that simple. Grep is a tool that will print every line that contains the string of characters from its first argument.

Output might be a little bit big. If you want to be able to scroll, search use Home/Eng/PgDown/PgUp keys and save it, use the less tool.

$ grep Trident access_log | less



If you don't have a big logfile or a webserver, you can test it on dmesg, a program that prints the kernel messages since last system boot

$ dmesg | less
. Try to run dmesg with and without | less.

I'll continue.
>>
File: 1329064449386.jpg (20KB, 300x228px) Image search: [Google]
1329064449386.jpg
20KB, 300x228px
>>45809708
nice beginners guide, will keep lurking
>pic somewhat related
>>
>>45809708
Cont:

|
, sometimes called a pipe.

Well, what really a pipe is?

$ grep blue

This will be waiting for your input. If you enter something that contains blue, it'll repeat that line, printing it to the output, out console. When you click Ctrl-D, the shell sends the EOF End-Of-File character, that should end grep.
But what if the output is not our console?

$ grep blue > allblues

this thing will collect everything you type to the console, search for blue in it and send it to the file 'allblues'.

You can even do this:
$ echo $MyCoolVariable > myvariable.txt
. Be careful. When the file already exists, ">" will delete is content and put what it want to put there.

To override this behaviour, you can use ">>".

For example, the "date" command output something like this:
Sat Dec 27 23:11:13 CET 2014
.

You can type
$ date >> all_dates.txt
a couple of times, when there is no file ">>" will create it. We can use the "cat" command to see the content of a file:
$ cat all_dates.txt
Sat Dec 27 23:12:41 CET 2014
Sat Dec 27 23:12:43 CET 2014
Sat Dec 27 23:12:45 CET 2014
Sat Dec 27 23:12:46 CET 2014
Sat Dec 27 23:12:48 CET 2014



The cat command without any arguments just repeats and print what is given to it.
$ cat
EEEECHOOOO!
EEEECHOOOO!
Don't yell at me!
Don't yell at me!


We can redirect it to a file as any other command.
$ cat > cat_output
ECHOO!
Nobody there?
*clicked ctrl-d*
$ cat cat_output # I'm not typing what is below me:
ECHOO!
Nobody there?



I'll continue.
>>
>>45810397


$ grep --help
...
-v, --invert-match select non-matching lines
...



So, with those things we can now match a file with a couple of strings. Let's say we want to find lines that contain banana but doesn't contain apple.

$ cat > file1
we paste our file there
$ grep banana file1 > file2
$ grep -v apple file2

Ouch. Looks bad, doesn't it? Well, that's because we don't know yet how to redirect to another program, and only to a file.
The correct code would look like that:
$ grep banana | grep -v apple


Why doesn't the second grep ask us to paste the contents for it? Well, the seconds grep's input is the first grep's output and the second grep's output is the terminal.

Let's start speaking in the unix terms here.
The input of the program is called stdin.
The output is called stdout.
There's also stderr.

In unix everything is a file.
Every one of this streams has a virtual file,
/dev/stdin, /dev/stdout, /dev/stderr


The cat program by default is just reading the /dev/stdin file. That's why
$ cat /dev/stdin
has the same effect as just
$ cat
.

The terminal output is called a tty - the virtual file is
/dev/tty
.

So in our example above, the two launched grep programs are doing the same thing. Reading from stdin, and outputing filtered text to stdout. But the OS is doing for us that:
$ grep banana            |    grep -v apple
input: tty input: stdin
output: stdout output: tty


With ">>" and ">", there are others: "2>", "&>", "<"

I'll continue.
>>
Hello everyone, I accidentally just wiped my entire /home folder playing around with an interactive file manager I was writing in bash. Let this be a lesson to always double check scripts, especially ones that use the rm command.

Well, Once I reboot everything is fucked, but I just installed this system anyway so it's no big deal. I guess this is what VMs are for. This is my last post on this system, so good luck everyone.
>>
>>45810746

Good job anon
>>
>>45810971
Just quickly do
$ mkdir /home/yourname
and set permissions. System should work without a home folder anyway.
>>
>>45810746
Cont:

Well, what is really that stderr?
When normal stdout can be manipulated by the ">" and ">>" operators, we can also use the "1>" and "1>>" operators. They are the same, try it.
Stderr can be manipulated when we use the "2>" and "2>>" operators.

The
|
pipes doesn't redirect the stderr. So if you had something like this:
$ grep banana | grep --asdfdasfsfdasfasd fruit | grep black

The output will be:
 grep: unrecognized option '--asdfdasfsfdasfasd'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
even if there is that
| grep black
at the end.

So the stderr is just a nice way for programs to tell us about errors.

We can redirect stderr to stdout, by just doing "2>/dev/stdout".

$ grep banana | grep --asdfdasfsfdasfasd fruit 2>/dev/stdout | grep Usage
Usage: grep [OPTION]... PATTERN [FILE]...


If you want to redirect both stderr and stdout to a file, you can use the "&>" and the "&>>" operators.

These are equivalent:
$ dmesg >>out 2>>out
$ dmesg 1>>out 2>>out
$ dmesg >> out 2>> out
$ dmesg 1>> out 2>> out
$ dmesg &>>out
>>
rebump >>45809296

Now with more content included!
>>
Well, they have these distros called Ubuntu and Mint.

I haven't used Ubuntu in a long time, but I installed Mint on my desktop earlier this year. Took about 15 mins and it worked without issue. Recognized my specific model of Wacom Tablet with no action taken on my end besides plugging it in.
>>
File: 4chan linux tips.png (969KB, 971x9621px) Image search: [Google]
4chan linux tips.png
969KB, 971x9621px
>>45812234
saved if anyone wants it
>>
>>45812831
Thanks.
>>
>>45807478
sudo rm -rf /

It'll install all of the necessary drivers the installer may have missed.
>>
>>45814044
This won't even remove anything without --no-preserve-root.
You are retarded.
>>
>>45807478

If you're not racist and don't mind some spicy Hindu's teaching you, then this is an absolutely excellent series of 1 hour long courses over nine days. It will get you from noob to a very solid foundation that it takes many years to learn.

http://www.youtube.com/playlist?list=PLq_0rAxohwfkbZSdZaw3M6s1vQEUDz_me
>>
Is this actually a helpful thread on /g/ about linux use

what the fuck is going on
>>
>>45810746
>>45811254
You should write textbooks
>>
>having to fucking write code to do basic things
Linux must be a fucking pain. I can't think of a legitimate reason to want to use it unless you want to make yourself feel like a matrix operator
>>
>>45818081
I actually learned to "write code to do basic things" when I was a toddler.

So you know, you are more retarded than I was when I was four.
>>
>>45818148
If you can't see what's wrong with this post then you are beyond help
>>
>>45818175
I neither need, nor want your help.
>>
>>45818198
It was not offered but I'm glad that a basic figure of speech went over your head and you took it literally, you truly are autistic
>>
>>45818223
You seem to be confused.
>>
>>45818238
Not at all but thanks for the affirmation of your completely unrelated response
>>
>>45807478
To start with, google about bash and unix shell commands.

Also.. don't ask /g/ anything, you will be trolled.
>>
>>45807478
>to get it running nice and smooth and to my liking
>translation: how does I ricerfag???

For that, google about window managers and configuration files for X, also themes for various gui kits (like gtk, etc).
>>
>>45818244
You also seem to have trouble constructing meaningful English language sentences.
Thread posts: 71
Thread images: 5


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.