[LINUX] UNIX super-basic commands

What is UNIX

** UNIX ** is a type of ** OS ** like ** Windows ** and ** macOS ** An OS specifically designed for servers, also known as ** "server OS" **

** UNIX ** has various compatible OS

Such

Among them, the most widely used is ** Linux ** There are many companies and organizations that distribute this ** Linux ** for free with their own configurations and functions, and the ** distribution format ** is called ** Distribution **.

** Typical Distribution **

Such These are slightly different OSs, but the basic commands are unified by the standard called POSIX. Since macOS is also an OS that has UNIX as its source, it can also be used in macOS terminals.

In the terminal, a program called ** Shell ** accepts user commands.

UNIX super-basic commands

Execute super-basic commands such as creating, moving, copying, and deleting directories and files.

mkdir directory creation

$ mkdir unix_lesson

cd directory move

$ cd unix_lesson/

pwd Represents the current position with an absolute PATH

$ pwd
/Users/User/unix_lesson

touch file creation

$ touch lesson1.txt

Display a list of files in the ls directory

$ ls
lesson1.txt

echo Display character string

$ echo Hello!
Hello!

echo character string> file name Write the character string to the file

$ echo Hey! > lesson1.txt

cat Display the contents of the file

$ cat lesson1.txt
Hey!

Copy the cp file

$ touch lesson2.txt       #Create a new file
$ cp lesson1.txt lesson2.txt  #lesson1.Copy the contents of txt
$ cat lesson2.txt         #Display contents
Hey!

mv Rename file or move file

** File name change ** mv (file name before change) (file name after change)

$ ls               #Check the contents of the directory
lesson1.txt lesson2.txt   
$ mv lesson1.txt unix.txt  #lesson1.Rename txt
$ ls
lesson2.txt	unix.txt

** Move files ** mv (file you want to move) (destination directory)

$ mkdir lesson_folder     #lesson_Create a directory called folder
$ mv unix.txt lesson_folder  #unix.txt lesson_Move to folder
$ cd lesson_folder/
$ ls
unix.txt

Delete the rm file

$ rm unix.txt

Delete the rmdir directory

$ rmdir lesson_folder

exit Exit the shell

$ exit
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[The process is complete]

Other commands

ps List running processes

$ ps
  PID TTY           TIME CMD
81600 ttys000    0:00.30 -bash

cal Display calendar

$ cal
December 2020
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
       1  2  3  4  5  
 6  7  8  9 10 11 12  
13 14 15 16 17 18 19  
20 21 22 23 24 25 26  
27 28 29 30 31        

date Display the current date and time

$ date
Thursday, December 24, 2020 19:15:06 JST

Search for find files

$ find unix_lesson/
unix_lesson/
unix_lesson//lesson2.txt

It's Christmas today. ..

Recommended Posts

UNIX super-basic commands
100 Language Processing Knock 2020 Chapter 2: UNIX Commands
[Language processing 100 knocks 2020] Chapter 2: UNIX commands
Linux commands
linux commands
Basic commands
Linux commands
Linux commands
100 Language Processing Knock UNIX Commands Learned in Chapter 2