카테고리 없음

top50 linux commands

RIEM 2023. 12. 9. 13:08
728x90

list

  1. ls
  2. pwd
  3. cd
  4. mkdir
  5. mv
  6. cp
  7. rm
  8. touch
  9. in
  10. cat
  11. clear
  12. echo
  13. less
  14. man
  15. unman
  16. whoami
  17. tar
  18. grep
  19. head
  20. tail
  21. diff
  22. cmp
  23. comm
  24. sort
  25. export
  26. zip
  27. unzip
  28. ssh
  29. service
  30. ps
  31. kill and killall
  32. df
  33. mount
  34. chmod
  35. chown
  36. ifconfig
  37. traceroute
  38. wget
  39. ufw
  40. iptables
  41. apt, pacman, yum, rpm
  42. sudo
  43. cal
  44. alias
  45. dd
  46. whereis
  47. whatis
  48. top
  49. useradd
  50. passwd

ls

list files and directories in the current working directory.

$ ls

pwd

print current working directory

$ pwd

cd

move to another directory

$ cd <directory path>

mkdir

make directories

$ mkdir <folder name>

cp and mv

cp for copy-paste. mv for renaming.

$ cp <source> <destination>
$ mv <source> <destination>

rm

rm for removing file

$ rm <file name>

touch

for creating a new file

$ touch <file name>

In

create link to another file

$ ln -s <source path> <link name>
$ New-File-Link -> New-File
drwxr-xr-x  3 hugo  staff  96 Jun 20 16:27 a
drwxr-xr-x  2 hugo  staff  64 Jun 20 16:27 b
-rw-r--r--  1 hugo  staff   0 Jun 20 16:27 bye.txt

$ ls -l
lrwxr-xr-x  1 hugo  staff   8 Jun 20 16:29 New-File-Link -> New-File
drwxr-xr-x  3 hugo  staff  96 Jun 20 16:27 a
drwxr-xr-x  2 hugo  staff  64 Jun 20 16:27 b
-rw-r--r--  1 hugo  staff   0 Jun 20 16:27 bye.txt

cat, echo, less

print output

// see the content of file
$ cat <file name>

// console.log 
$ echo <Text to print on terminal>

// use less keyword when content is larger than screen space
$ cat bye.txt | less

man

offer a fast way to know funcs of all packages that you can download

$ man <command>

uname and whoami

$ uname
$ uname -a

$ uname -a
Darwin Hugos-MacBook-Pro.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:46 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6020 arm64

tar, zip, and unzip

create and extract archived files in Linux. -c for create, x for extract.

# Compress
$ tar -cvf Compress.tar bye.txt

# Extract
$ tar -xvf Compress.tar
$ zip <archive name> <file names separated by space>
$ unzip <archive name>

grep

grep for searching specific string from an output

<Any command with output> | grep "<string to search>"
$ cat bye.txt

Hello guys.. welcome.

I am Grepper.

This is awesome :)

Thanks, my friend.

Kind regards,

Jin.


$ cat bye.txt | grep "Kind"

Kind regards,

head and tail

see only 10 lines of head or tail of file.

head <file name>
tail <file name>

diff, comm, cmp

diff for show differences

$ diff <file 1> <file 2>
$ diff bye.txt bye2.txt
11c11,13
< Jin.
---
> John.
>
> P.S. Today was great weather ;)

cmp tells line number location of difference

$ cmp bye.txt bye2.txt
bye.txt bye2.txt differ: char 95, line 11

comm show arranged differences

$ comm bye.txt bye2.txt

        Hello guys.. welcome.

        I am Grepper.

        This is awesome :)

        Thanks, my friend.

        Kind regards,

Jin.
    John.

    P.S. Today was great weather ;)

sort

sorted output of contents

sort <filename>
$ cat bye.txt

Hello guys.. welcome.

I am Grepper.

This is awesome :)

Thanks, my friend.

Kind regards,

Jin.



$ sort bye.txt




Hello guys.. welcome.
I am Grepper.
Jin.
Kind regards,
Thanks, my friend.
This is awesome :)

export

exporting environment variables in runtime

export <variable name> = <value>

PS1은 현재 프로파일명

hugo@Hugos-MacBook-Pro linuxCommands % export PS1="\u@\h:\w -->>"
\u@\h:\w -->>ls

ssh

connect to external machine on the network by using ssh protocol

ssh username@hostname

service

For starting and stopping different services within OS

root@ubuntu:~ -->> service ssh status
root@ubuntu:~ -->> service ssh stop
root@ubuntu:~ -->> service ssh start

ps, kill, killall

# find process
root@ubuntu:~ -->> ps 

# kill process
root@ubuntu:~ -->> kill <process ID>
root@ubuntu:~ -->> killall <process name>

df, mount

efficient utilities to mount filesystems and get details of file system.

# mount device to /mnt folder
$ mount /dev/cdrom /mnt

# show mounted device list
$ df

# show mounted devices list with % for readability
$ df -h

chmod and chown

for changing file permissions and file ownership.
chmode for changing file permission.
chown for chaning file owners.

chmod <param> filename
chown user:group filename
root@ubuntu:~ -->> chmod +x loop.sh
root@ubuntu:~ -->> chmod root:root loop.sh

ifconfig, traceroute

for managing network.
ipconfig for list of network interfaces to IP address

ifconfig

traceroute specify IP adress, the hostname or domain name of endpoint.

$ traceroute <destination address>
$ traceroute localhost

wget

for download from web. -c arg for resumming an interrupted download.

$ wget <link to file>
$ wget -c <link to file>

ufw, iptables

firewall interfaces for Linux Kernel's netfilter firewall.

IPTables for directly passing firewall rules to netfilter.
UFW for configuring the rules in IPTables which then sends those rules to netfilter.

UFW is easy version.
iptables is difficult version.

$ iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$ ufw allow 80

Package managers in linux

package managers are different depending on linux distro.

# Debian | Debian-based
$ apt install <package name>

# Arch | Arch-based
$ pacman -S <package name>

# Red Hat | Red Hat-based
# Fedora | CentOS
$ yum install <package name>

sudo

run command as root user with escalated privileges

sudo <command>

cal

$ cal
$ cal May 2023

alias

set alias

$ alias lsl="ls -l"

dd

convert and copy files from multiple file system formats.

dd if = /dev/sdb of = /dev/sda

if = input file
of = output file

whereis, whatis

whereis for output exact location of any command.
whatis for what is this command for.

whereis <command>
whereis sudo

whatis sudo

top

ps output active processes and end itself.

top is like CLI version of task manager in window. It shows a view of processes and all info like memory usage, CPU usgage, etc.

useradd, usermod

adduser for creating new user in Linux.

usermod for modifying existing users.

root@ubuntu:~# useradd JournalDev -d /home/JD
root@ubuntu:~# usermod JournalDev -a -G sudo, audio, mysql

passwd

set password for account

passwd

Reference

728x90