21 Kasım 2016 Pazartesi

Note to myself

apt-get -f upgrade
apt-get update
dpkg -i bla bla bla

http://www.thegeekstuff.com/2009/04/vi-vim-editor-search-and-replace-examples/

http://www.tecmint.com/wc-command-examples/

http://www.thegeekstuff.com/2012/10/15-linux-split-and-join-command-examples-to-manage-large-files/

http://www.livefirelabs.com/unix_commands/5-unix-diff-command-examples-of-how-to-compare-two-text-files.htm

http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

https://www.cyberciti.biz/tips/howto-keep-file-safe-from-overwriting.html

19 Kasım 2016 Cumartesi

Creating group, giving sudo privileges and adding user to the group

Step 1: Login to root account
..$ su

Step 2: Adding user
..# useradd -m frank

Step 3: Creating group
..# groupadd rangers

Step 4: Edit sudoers and add rangers into
..# vim /etc/sudoers

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
%rangers  ALL=(ALL:ALL) ALL

save and exit

Step 5: Adding frank to rangers
..# usermod -a -G rangers frank

Finished.
Now you have a user frank in the rangers group, which was added to sudoers file.
You should able to use sudo while you are frank.

locate command

Before using locate  command, you should update db
..$ sudo updatedb

then you can use locate.
..$ locate mypicture

18 Kasım 2016 Cuma

Fast Search


There are couple of ways to make searching.

One of them:

ls | grep

..$ ls | grep dir
workingdir
direct
dire

It shows us anything contains dir.



note:
cat /etc/issue

shows you to which os currently you have.

5 Ekim 2016 Çarşamba

Internal and External Commands

Internal commands are buil-in commands.
If you don't know the type of a command, you can use "type" command:


..$ type cd
cd is a shell builtin

..$ type pwd
pwd is a shell builtin

..$ type bash
bash is /bin/bash

There is a trick about "type" command:

..$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd

"-a" option shows us is the command duplicated by external command or not.
let's understand it with "time" command:

..$ time pwd
/home/user

real 0m0.000s
user 0m0.000s
sys 0m0.000s

..$/usr/bin/time pwd
/home/user
0.00user 0.00system 0:00.04elapsed 0%CPU
(0avgtext+0avgdata 2240maxresident)k
64inputs+0outputs (1major+83minor)pagefaults 0swaps

So what happened up there:
When we typed "time pwd" we used the internal(built-in) time command
Then we typed "/usr/bin/time pwd"    that was the external time command
I hope this is a helpful explanation about difference between internal and external commands.

26 Eylül 2016 Pazartesi

Appending multiple files into a single file

Let's assume you have file1.txt file2.txt file3.txt
Open the terminal and...

..$ cat file1.txt file2.txt file3.txt > file4.txt

VIM tricks:
*While you are in normal mode you can press "ZZ" to save and exit quickly
*You can go insert mode to below the current line with pressing "o" button
*If you want to delete current line quickly in normal mode, you should press "dd"

20 Eylül 2016 Salı

Note to myself


/etc/apt/sources.list    holds the archive region

http://unix.stackexchange.com/questions/88644/how-to-check-os-and-version-using-a-linux-command          os information

/dev info
http://linuxboxadmin.com/articles/tools-and-utilities/linux-file-permissions-beyond-rwx.html

char and block file
http://www.linuxnix.com/linuxunix-difference-between-char-and-block-file/

18 Eylül 2016 Pazar

user is not in the sudoers file


sudo vim /etc/sudoers


#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges


you sould add your user below the "root ALL=(ALL:ALL) ALL" like this:

# User privilege specification
root    ALL=(ALL:ALL) ALL
user    ALL=(ALL:ALL) ALL

13 Eylül 2016 Salı

some important things for me

lsb_release -a
cat /etc/lsb-release 
to learn os

adduser username
usermod -aG sudo username
su - username
to add user and switch to it


userdel mynewuser
userdel -r mynewuser
visudo
mynewuser ALL=(ALL:ALL) ALL
to delete user


ps aux and top


Command 1. Using wget

# wget http://ipecho.net/plain -O - -q ; echo

Command 2: Using curl

# curl ipecho.net/plain; echo

Command 3: Using wget

# wget http://observebox.com/ip -O - -q ; echo

Command 4: Using curl

# curl icanhazip.com

Command 5: Using curl

# curl ifconfig.me
to get public ip

12 Eylül 2016 Pazartesi

Adding and Removing User in Ubuntu


 First login to root:

..$ su
..root# adduser fly
Adding user `fly' ...
Adding new group `fly' (1001) ...
Adding new user `fly' (1001) with group `fly' ...
Creating home directory `/home/fly' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for fly
Enter the new value, or press ENTER for the default
Full Name []: 
Room Number []: 
Work Phone []: 
Home Phone []: 
Other []: 
Is the information correct? [Y/n] y
..root#

After adding user fly we can add it to the sudo group:

..root# usermod -aG sudo fly
..root#

Now we should switch the fly:

..root# su - fly
..fly$


If you want to delete it
Close and reopen the terminal
Login as a root:

..root# userdel -r fly







4 Eylül 2016 Pazar

for loop in linux terminal

   I have a folder which has 3 files:

..$ ls
file1 file2 file3

Let's make a for loop:

..$ for x in `ls`
> do
> echo $x
> done;

The output:

file1
file2
file3


The most important thing is the backtick.

This is a backtick:    `  
And when we use the ls in loop, we need double backtick:
 
   `ls`

If you don't know where the backtick button is on your keyboard, you can search the images in google.

3 Eylül 2016 Cumartesi

test command

   Varsayalım ki bulunduğunuz directory içinde file1 ve file2 olmak üzere 2 file var.
test command ile ne yapabileceğimize bakalım:

..$ test -f file1
..$

Gördüğünüz üzere herhangi bir çıktı almadık.

..$ test -f file1 && echo "true"
true

test -f komutu bize file check etmemiz için gerekli.
Ardından gelen file1, check etmek istediğimiz file.
&& :  if it's true anlamına gelir.
echo "true" :  true çıktısı verir.

..$ test -w file1 && echo "true"
true

Yukarıda yaptığımız şey ise file 1 in writable olup olmadığını gösterdi. -w flag i -writable anlamına gelmektedir.


Şimdi biraz daha farklı bir şey deneyelim:

..$ test 1 -gt 2 && echo "true"
..$


Eğer 1 is greater than 2 ekrana true yaz. görüldüğü üzere herhangi bir çıktı almadık.
-gt flag i greater than anlamına gelmektedir.

..$ test 2 -gt 1 && echo "true"
true


İf it's false
double pipe : | |

..$ test 1 -gt 2 && echo "true" | | echo "false"
false


if it's equal

..$ [ 5 -eq 5 ]; echo $?
0

..$ [ 5 -eq 6 ]; echo$?
1

Doğruluk durumunda 0
Yanlışlık durumunda 1 çıktısı aldık.

..$ [ 5 = 5 ]; echo $?
0

..$ [ 5 = 6 ]; echo $?
1

test command ile yaparsak:

..$ test 5 -eq 6 && echo "true" | | echo "false"
false


kaynak: linuxacademy.com

31 Ağustos 2016 Çarşamba

Lenovo Yoga 500 ve Ubuntu 16.04

  Bu ilk yazıda yeni aldığım ve Ubuntu 16.04 yüklediğim Lenovo Yoga 500'den bahsetmek istiyorum.
i3 işlemci ve paylaşımlı ekran kartı içeren bu cihaz 500 gb hdd ile geliyor. Bünyesinde Windows 10 Home barındıran bu hdd yi söküp yerine 120 gb ssd taktım ve Ubuntu 16.04 yükledim.
  Öncelikle Ubuntu yüklemeden önce cihazın bazı fonksiyonlarını kullanamayabileceğimi düşünmüştüm, dokunmatik ekran ve ışıklı klavye gibi. Fakat herhangi bir sorun yaşamadan fonksiyonel biçimde kullanabiliyorum cihazı.

Eğer sizde Ubuntu yüklemek isterseniz http://www.ubuntu.com adresinden indirebilirsiniz.
Usb diskinize mount etmek için de https://rufus.akeo.ie adresinden Rufus'u indirip kullanabilirsiniz.
Kullandığınız bilgisayara ssd takmak istiyorsanız Youtube'da [bilgisayar adı ve modeli][ssd upgrade]
şeklinde arama yaparak ilgili disassembly videolarına ulaşabilirsiniz.

Bu ilk yazı giriş niteliğinde olup devam eden yazılarda digital literacy başta olmak üzere GNU/Linux
hakkında paylaşımlar yapacağım.