• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

display

Display certain lines in a file

March 23, 2023

This will display only lines 40-50 in a file called lines.txt.

$ cat lines.txt | head -n 50 | tail -n 10

$ cat lines.txt | head -n 50 | tail -n 10

For lines 90-100.

$ cat lines.txt | head -n 100 | tail -n 10

$ cat lines.txt | head -n 100 | tail -n 10

and so on.

Filed Under: Linux Tagged With: cat, display, head, lines, tail

Memory Info on Linux

March 15, 2023

Here’s how to view system memory on Linux.

Default display is in kB

cat /proc/meminfo
MemTotal:        7492768 kB
MemFree:          427368 kB
MemAvailable:    5424768 kB

cat /proc/meminfo MemTotal: 7492768 kB MemFree: 427368 kB MemAvailable: 5424768 kB

Display in MB

awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t
MemTotal:           7317.16      MB
MemFree:            404.527      MB
MemAvailable:       5285.4       MB

awk '$3=="kB"{$2=$2/1024;$3="MB"} 1' /proc/meminfo | column -t MemTotal: 7317.16 MB MemFree: 404.527 MB MemAvailable: 5285.4 MB

Output in GB

awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t
MemTotal:           7.14566      GB
MemFree:            0.370392     GB
MemAvailable:       5.13733      GB

awk '$3=="kB"{$2=$2/1024^2;$3="GB";} 1' /proc/meminfo | column -t MemTotal: 7.14566 GB MemFree: 0.370392 GB MemAvailable: 5.13733 GB

Filed Under: Linux Tagged With: display, linux, meminfo, memory, proc

Linux prompt display current directory only

February 11, 2022

Here’s the command to display only the current directory.

export PROMPT_DIRTRIM=1

export PROMPT_DIRTRIM=1

Place the command in your ~/.bashrc to make it permanent.

Filed Under: Linux Tagged With: current, directory, display, only, prompt

GCP Display Roles on Service Account

October 6, 2021

How to display roles assigned to a GCP service account.

gcloud projects get-iam-policy your-project-id \
--flatten="bindings[].members" \
--format='table(bindings.role)' \
--filter="bindings.members:your-service-account@your-project.iam.gserviceaccount.com"

gcloud projects get-iam-policy your-project-id \ --flatten="bindings[].members" \ --format='table(bindings.role)' \ --filter="bindings.members:your-service-account@your-project.iam.gserviceaccount.com"

Result

ROLE
organizations/xxxxxxxxxxxxx/roles/role-name
roles/compute.instanceAdmin.v1
roles/compute.networkViewer
roles/logging.logWriter
roles/monitoring.metricWriter

ROLE organizations/xxxxxxxxxxxxx/roles/role-name roles/compute.instanceAdmin.v1 roles/compute.networkViewer roles/logging.logWriter roles/monitoring.metricWriter

Filed Under: Cloud Tagged With: display, gcp, project, roles, service account

GCP Display Device Names on OS

August 18, 2021

In GCP console you can see the VM’s Device Names. In this case, it’s boot and persistent-disk-1.

Name		          Device name
server-boot               boot	
server-data               persistent-disk-1

Name Device name server-boot boot server-data persistent-disk-1

To display the volume names on the OS, run this command.

$ ls -l /dev/disk/by-id
total 0
lrwxrwxrwx. 1 root root  9 Aug  2 01:12 google-boot -> ../../sda
lrwxrwxrwx. 1 root root 10 Aug  2 01:12 google-boot-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Aug 18 18:48 google-persistent-disk-1 -> ../../sdb
lrwxrwxrwx. 1 root root  9 Aug  2 01:12 scsi-0Google_PersistentDisk_boot -> ../../sda
lrwxrwxrwx. 1 root root 10 Aug  2 01:12 scsi-0Google_PersistentDisk_boot-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Aug 18 18:48 scsi-0Google_PersistentDisk_persistent-disk-1 -> ../../sdb

$ ls -l /dev/disk/by-id total 0 lrwxrwxrwx. 1 root root 9 Aug 2 01:12 google-boot -> ../../sda lrwxrwxrwx. 1 root root 10 Aug 2 01:12 google-boot-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 9 Aug 18 18:48 google-persistent-disk-1 -> ../../sdb lrwxrwxrwx. 1 root root 9 Aug 2 01:12 scsi-0Google_PersistentDisk_boot -> ../../sda lrwxrwxrwx. 1 root root 10 Aug 2 01:12 scsi-0Google_PersistentDisk_boot-part1 -> ../../sda1 lrwxrwxrwx. 1 root root 9 Aug 18 18:48 scsi-0Google_PersistentDisk_persistent-disk-1 -> ../../sdb

As you can see, boot and persistent-disk-1 are displayed along with its device names /dev/sda and /dev/sdb.

Filed Under: Cloud, Linux Tagged With: disks, display, gcp, id, names, volumes

Display Sequential Write Throughput

February 5, 2020

Here’s a dd command to display sequential write throughput from the command line.

time dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress

time dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress

Output is.

512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s
 
real    0m0.669s
user    0m0.000s
sys     0m0.359s

512+0 records in 512+0 records out 536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s real 0m0.669s user 0m0.000s sys 0m0.359s

Filed Under: Linux Tagged With: dd, display, sequential, terminal, throughput, write

Windows Route Add

January 14, 2020

Here’s how to add a route in Windows. Open CMD as Administrator.

route add 10.10.10.10 mask 255.255.255.0 10.10.10.254

route add 10.10.10.10 mask 255.255.255.0 10.10.10.254

To make it persistent, add -p.

route add 10.10.10.10 mask 255.255.255.0 10.10.10.254

route add 10.10.10.10 mask 255.255.255.0 10.10.10.254

To display. Specifies IP 4 only.

route print -4

route print -4

Filed Under: Windows Tagged With: add, display, permanent, persistence, print, route, server, windows

Windows + Tab

September 18, 2019

Found another gem to display all Windows by using …

Windows + Tab

Windows + Tab

Filed Under: Misc Tagged With: all, display, tab, windows

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023