Skip to content

Linux

Linux komut satırı notları: dosya sistemi, kullanıcılar, servisler, ağ ve günlük yönetim komutları.

10 min read

How to pronounce Linux

Internet newsgroup participants have long debated the proper pronunciation of Linux. Because the name Linux was conferred by Linux kernel author Linus Torvalds, his pronunciation of the word should reign as standard as I see it. However, Linus is Finnish and his pronunciation of Linux is difficult for English speakers to approximate. Consequently, many variations in pronunciation have arisen. The most popular pronunciation sounds as though the word were spelled Linnucks, with the stress on the first syllable.

You can hear how Linus Torvalds pronounces Linux:

Andrew T. Baker - Demystifying Docker - PyCon 2015

How to pronounce Linux

Directory structure

  • /boot: Boot loader files
  • /etc: Configuration files
  • /home: User home directories
  • /root: Root home directory
  • /opt: Third-party applications
  • /dev: Device files
  • /var: Variable files
  • /bin: User binaries
  • /sbin: System binaries
  • /usr: User applications
  • /proc: Process information
  • /mnt: Mount directory
  • /sys: Virtual file system
  • /media: Removeable devices
  • /run: Temporary file system
  • /tmp: Temporary files
  • /lost+found: Recover broken files
  • /lib: System libraries
  • /srv: Service data directory

Changing locale

Edit locale.gen and comment out the locale you need, for example tr_TR.UTF-8 UTF-8

Terminal window
nano /etc/locale.gen

Then run locale-gen command for activation

Terminal window
locale.gen

Changing tzdata (time zone)

Terminal window
dpkg-reconfigure tzdata

Listening live stream

Terminal window
mplayer <stream>
mplayer -nocache -afm ffmpeg <stream>

Some internet radios

apt (aptitude)

/etc/apt/sources.list.d/ is a directory where you can add additional sources for apt. For example, you can add a PPA (Personal Package Archive) to install software that is not available in the default repositories.

Terminal window
# Add a PPA
sudo add-apt-repository ppa:example/ppa
# Update package list
sudo apt update
# Install a package
sudo apt install package-name

*.sources files are used to define additional sources for apt.

antigravity.sources
Types: deb
URIs: https://us-central1-apt.pkg.dev/projects/antigravity-auto-updater-dev/
Suites: antigravity-debian
Components: main
Architectures: amd64
Signed-By: /etc/apt/keyrings/antigravity-repo-key.gpg
tor.sources
Types: deb deb-src
URIs: https://deb.torproject.org/torproject.org/
Suites: trixie
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/deb.torproject.org-keyring.gpg

Converting video

Terminal window
ffmpeg -i video1.m4v -acodec copy -vcodec copy -f mov video1.mov

Splitting video

Terminal window
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss START -t LENGTH OUTFILE.mp4

where START is starting positing in seconds or in format hh:mm:ss LENGTH is the chunk length in seconds or in format hh:mm:ss

If let’s say your video is 31 minutes long and you want so split into 15 min chunks here is how you run it:

Terminal window
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 0 -t 00:15:00 OUTFILE-1.mp4
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 00:15:00 -t 00:15:00 OUTFILE-2.mp4
ffmpeg -i ORIGINALFILE.mp4 -acodec copy -vcodec copy -ss 00:30:00 -t 00:31:00 OUTFILE-3.mp4

Commands

To set home directory

Terminal window
usermod –d /home/user1/

To set root gid and groups for the user1

Terminal window
usermod –g 0 –G 0 user1

To change access rights for a directory

Terminal window
chmod 777 /var/www/directory

To remove package with configuration files

Terminal window
aptitude remove --purge package-name

To remove old configuration files

Terminal window
dpkg --purge package-name

To combine .rar files using unrar

Terminal window
unrar e -kb part01.rar

RarCrack

Terminal window
rarcrack p1r.part1.rar

Creating symbolic link (There is no ”/” sign at the end)

Terminal window
ln -s /var/www/existing /var/www/newname

Burning an ISO image to CD-ROM

Terminal window
apt-get install cdrecord
cdrecord -scanbus
... snip ...
1,0,0 100) 'HDT72251' '6DLAT80 ' 'V43O' Disk
1,1,0 101) *
1,2,0 102) *
... snip ...
cdrecord -dev 1,0,0 /tmp/output.iso

Removing kernel

Terminal window
uname –a
dpkg --list 'linux-image*'
sudo aptitude remove linux-image-2.6.18-5-686

Sources List, http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html

Terminal window
nano /etc/apt/sources.list

Trace a program (ex. pidgin)

Terminal window
strace -v -i -s 9999 $( which pidgin ) >| strace.log 2>&1

nc

To check if a port is free, run the following command:

Terminal window
$ nc localhost 56733 < /dev/null; echo $?

If the output of the command above is 1, then the port is free and usable.

xattr (extended attributes)

Delete ‘Where From’ metadata from files

Terminal window
xattr /Path/To/File

You’ll get a key named com.apple.metadata:kMDItemWhereFroms. To delete this key in the Terminal, run:

Terminal window
xattr -d com.apple.metadata:kMDItemWhereFroms /Path/To/File

Mount External HDD (NTFS)

Install ntfs-3g library

Terminal window
aptitude install ntfs-3g

Shows all the disk drives

Terminal window
fdisk -l

To make writable mount

Terminal window
mount /dev/sda1 /mnt/sda1 -t ntfs-3g -o rw,umask=0022,uid=dev,gid=dev

Mount NTFS partition

umask is a filter of permissions, so it works in the opposite way to chmod. Full permissions are equivalent to 777 (rwxrwxrwx). A umask of 0222 (-w—w—w-) leaves 555 (r-xr-xr-x).

Terminal window
mount /dev/sda1 /mnt/sda1 -t ntfs -r -o umask=0222,uid=dev,gid=dev

-rwxr-x--- 1 dev dev 28096 Aug 24 1996 chkdsk.exe

Terminal window
umount /mnt/sda1/

To make writable mount

Terminal window
mount /dev/sda1 /mnt/sda1 -t ntfs-3g -o rw,umask=0022,uid=dev,gid=dev

Mount an ISO image

Under UNIX and Linux like oses a loop device (a pseudo-device) can make a file accessible as a block device. It is is often used for CD / DVD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory.

Open terminal and create a mount point:

Terminal window
sudo mkdir /home/user/iso

If your iso image is at /tmp/file.iso, type the following to mount it:

Terminal window
sudo mount -o loop /tmp/file.iso /home/user/iso

To unmount type the command:

Terminal window
sudo umount /home/user/iso

Accurate Platform Detection

Terminal window
shtool platform -v -F "%sc (%ac) %st (%at) %sp (%ap)"
cat /etc/*-release

Network Testing Basics

Install netkit-ping, traceroute, dnsutils, ipchains (for 2.2 kernel), iptables (for 2.4 kernel), and net-tools packages and:

Terminal window
ping google.com # check Internet connection
traceroute google.com # trace IP packets
ifconfig # check host config
route -n # check routing config
dig [@dns-server.com] host.dom [{a|mx|any}] |less # check host.dom DNS records by dns-server.com for a {a|mx|any} record
ipchains -L -n |less # check packet filter (2.2 kernel)
iptables -L -n |less # check packet filter (2.4 kernel)
netstat -a # find all open ports
netstat -l --inet # find listening ports
netstat -ln --tcp # find listening TCP ports (numeric)

How to format a hard drive in linux

To create partition on hard drive B

Terminal window
cfdisk /dev/sdb

Choose New, Primary and then Write and Quit

To format 1st partition on hard drive B

Terminal window
mkfs /dev/sdb1

convert images to pdf

Use convert program (it is an executable installed as part of Imagemagick suite of tools):

Terminal window
convert 'p%d.jpg[1-148]' file.pdf
convert "*.{ext1,ext2,ext3,...}" -quality 100 outfile.pdf

Convert svg to png

Change dpi, width and height

Terminal window
inkscape input.svg --export-filename=output.png --export-dpi=300 --export-width=1500 --export-height=500

Create favicon.ico

Using netpbm and GIMP

Install netpbm and GIMP

Terminal window
aptitude install netpbm gimp

Step # 1: Convert logo to ppm raw format

  1. Open your logo using GIMP
  2. Now cut and paste logo in square
  3. Next resize logo by visiting Image > Scale image option. Set pixel size to 16 x 16 or 32 x 32 or 48 x 48.
  4. Next click on File > Save as > Enter file name as favicon.ppm > Click on Save > Raw Encoding > Ok

Step # 2: Convert portable pixmaps into a Windows .ico file

Terminal window
ppmtowinicon -output favicon.ico favicon.ppm

Using imagemagick

Install imagemagick first

Terminal window
brew install imagemagick

and use convert tool

Terminal window
convert -background transparent icon.png -define icon:auto-resize=16,32,48,64,256 icon.ico

How to cycle through reverse-i-search in BASH?

To cycle through alternatives by repeatedly hitting Ctrl+R

E.g.:

Terminal window
Ctrl+R grep Ctrl+R Ctrl+R ...

Convert png image to jpg with white background

Terminal window
mogrify -format jpg -background white -flatten *.png

xattr

Using the xattr command, you can inspect the extended attributes:

Terminal window
$ xattr s.7z
com.apple.metadata:kMDItemWhereFroms
com.apple.quarantine

and use the -d option to delete one extended attribute:

Terminal window
$ xattr -d com.apple.quarantine s.7z
$ xattr s.7z
com.apple.metadata:kMDItemWhereFroms

you can also use the -c option to remove all extended attributes:

Terminal window
$ xattr -c s.7z
$ xattr s.7z

Checking the SHA-256 checksum

You can compare the SHA-256 checksum of your downloaded binary against the checksums that are provided for every release. To generate a SHA-256 checksum of your downloaded binary, then open the corresponding checksum file and ensure that it contains the same number.

Terminal window
$ shasum -a 256 downloaded_binary.tar.gz

Getting all files from a web page using wget

For downloading files from a directory listing, use -r (recursive), -np (don’t follow links to parent directories), and -k to make links in downloaded HTML or CSS point to local files

Terminal window
wget -r -np -k [web_address]

Other useful options:

  • -nd (no directories): download all files to the current directory
  • -e robots.off: ignore robots.txt files, don’t download robots.txt files
  • -A png,jpg: accept only files with the extensions png or jpg
  • -m (mirror): -r —timestamping —level inf —no-remove-listing
  • -nc, —no-clobber: Skip download if files exist

How to repartition and format a USB Stick

If your disk has been formatted incorrectly or has multiple partitions on it, its capacity may appear to be less than it should be. To fix this and regain full capacity, you need to repartition and format the disk.

To find out which disk is your USB drive

Terminal window
diskutil list

If the disk is /dev/disk2, to format the disk

Terminal window
sudo diskutil eraseDisk FAT32 USBNAME MBRFormat /dev/disk2

How to Make a Bootable USB Stick from an ISO File

How to create a Windows 11 bootable USB from macOS

Use balenaetcher

Terminal window
brew install balenaetcher

or from Mac

  1. Download the desired file
  2. Convert the .iso file to .img using the convert option of hdiutil:
Terminal window
hdiutil convert -format UDRW -o /path/to/target.img /path/to/source.iso

Note: OS X tends to put the .dmg ending on the output file automatically. Rename the file by typing:

Terminal window
mv /path/to/target.img.dmg /path/to/target.img
  1. Run diskutil list to get the current list of devices

  2. Insert your flash media 5 .Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2)

  3. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command - in the previous example, N would be 2)

  4. Execute sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m (replace /path/to/downloaded.img with the path where the image file is located; for example, ./ubuntu.img or ./ubuntu.dmg).

Note: Using /dev/rdisk instead of /dev/disk may be faster.

Note: If you see the error dd: Invalid number ‘1m’, you are using GNU dd. Use the same command but replace bs=1m with bs=1M.

Note: If you see the error dd: /dev/diskN: Resource busy, make sure the disk is not in use. Start the ‘Disk Utility.app’ and unmount (don’t eject) the drive.

  1. Run diskutil eject /dev/diskN and remove your flash media when the command completes

Now the USB stick is ready. Boot the device that you want from the USB stick.

sha3sum: Keccak, SHA-3, SHAKE, and RawSHAKE checksum utilities

Terminal window
sha3sum somefile.txt > somefile.txt.sha3
cat somefile.txt.sha3
765597429418c1b6e4a0d1ad52f2e3feb39c09e0709290571afad07f somefile.txt

Log Parsing Cheat Sheet

Log Parsing Cheat Sheet 1

Log Parsing Cheat Sheet 2

Finding and counting duplicate filenames

Terminal window
find . -name "*.java"|awk -F"/" '{a[$NF]++}END{for(i in a)if(a[i]>1)print i,a[i]}'

Modemin WAN şifresini bulmak

*Superonline WAN/Fiber kullanıcı şifresi öğrenme *Modemin WAN şifresini bulmak

Modemdeki WAN kablosunu sökün. Kablosuz kullanıyorsanız modem ile bağlantı yapmak için ethernet kablosu gerekiyor. Kablolu da kablosuz da bağlansanız, ethernet kablosunun bir ucunu bilgisayarınıza bağlayın, diğer ucunu ise modemin WAN girişine bağlayın.

Terminal window
sudo su
apt install pppoe

pppoe paketi yüklendikten sonra uçbirimi kapatmayın. etc/ppp dizinine gidin. Bunun için yine sol altta Files/Dosyalar kısayoluna tıklayın, dosya yöneticisi açılacak. Sol tarafta File System/Dosya Sistemi’ne tıklayın. Sonra sırasıyla etc ve ppp klasörlerine tıklayın. ppp klasöründe pppoe-server-options adında yeni belge oluşturmanız gerekiyor. Boşluk olan kısma sağ tıklayıp, Open as root/Yönetici haklarıyla aç’a basın. Başka bir pencerede aynı klasör açılacak, ancak yukarıda Elevated Privileges/Yükseltilmiş Ayrıcalıklar yazması gerek. Create New Document/Yeni Belge Oluştur’dan pppoe-server-options isimli boş belgeyi oluşturun. Yine aynı pencereden oluşturduğunuz dosyayı açıp içine aşağıdakileri kopyalayıp, kaydedip belgeyi kapatın.

Terminal window
require-pap
login
lcp-echo-interval 10
lcp-echo-failure 2
show-password
debug
logfile /var/log/pppoe-server-log

Bundan sonraki işlem ise pap-secrets isimli belgenin içine aşağıdaki kodu eklemek. xxxxx yerine ise kendi fiber kullanıcı adınızı yazacaksınız. Modem arayüzünden bakabilirsiniz kullanıcı adınıza. Kodu ekledikten sonra kaydetmeyi unutmayın.

Terminal window
# Secrets for authentication using PAP
# client server secret IP addresses
"xxxxx@fiber" * ""

Uçbirimde kaldığımız yerden devam ediyoruz. Aşağıdaki kodları sırasıyla yazın.

Terminal window
touch /var/log/pppoe-server-log
chmod 0774 /var/log/pppoe-server-log

Bir sonraki komut için kendi bilgisayarınıza göre düzenleme yapmanız gerekiyor. Bunun için öncelikle aşağıdaki komutu yazın.

Terminal window
iwconfig

iwconfig

Uçbirim bu şekilde bir çıktı verecektir. E ile başlayan çıktıyı sıradaki komutta kullanmamız gerekiyor. Örneğin burada eth0 olarak verdiği için sıradaki komut aşağıdaki şekilde olmalı. Ayrıca kendi çıktınıza göre düzenlediğiniz komutu vermeden önce belirttiğim şekilde bilgisayarınız ile modem arasındaki bağlantıyı kurun.

Terminal window
pppoe-server -F -I eth0 -O /etc/ppp/pppoe-server-options

Komutu verdikten sonra uçbirim çalışmaya devam edecek. Mevcut olan uçbirimi kapatmadan, yeni bir uçbirim açın ve aşağıdaki komutu verin.

Terminal window
sudo tail -f /var/log/pppoe-server-log

Ekrana çıktılar gelmeye başlayacak. Çıktılar arasında kullanıcı adınız ve şifreniz de olacak. Kimi bilgisayarda 1-2 dakika kadar beklemeniz gerekebilir şifre çıktısı için. Şifrenizi aldıktan sonra modeminizi kapatın, normal bağlantılarını yapıp tekrar başlatın.

Related articles

1 min read

gnome

Making the GNOME login screen ask for a username instead of showing the user list.

  • Linux & Systems
2 min read

Jitsi

Self-hosting Jitsi Meet: installation, Let's Encrypt, firewall rules, secure meetings and monitoring.

  • Linux & Systems
1 min readTürkçe

Steam

Linux'ta Steam ve Counter-Strike 2: GPU ayarları ve başlatma seçenekleri.

  • Linux & Systems

Type to search the whole site.