Linux command notes
Shell - a program that takes commands from keyboard and gives them to the operating system to perform.
Nowadays we have graphical user interfaces in addition to command line interfaces such as the shell.
On most linux system a bash acts as the shell program.
Terminal - a program that gets you interact with the shell.
A. Navigation
- pwd - prints current directory
- cd - changes directory
- ls - list files and directories
B. Looking around
- Ls - list files and directories
ls -l - list the files in the working directory in long format
ls -la - list all files including the hidden ones
- Less - view text files
- File - classify a file’s contents
Most commands operate in this pattern:
command -options arguments
C. A guided tour
symbolic links allows for multiple version of the same directory. Use ln command
D. Manipulating files
- Cp - copy files and directories
- Mv - move or rename files and directories
- Rm - remove files and directories
- Mkdir - create directories
http://linuxcommand.org/lc3_lts0050.php
E. Working with commands
- Type - display information about command type
- Which - locate a command
- Help - display reference page for shell builtin
- Man - display an on-line command reference
Commands can be one of 4 different kinds:
- An executable program like all those files we saw in /usr/bin. Within this category, programs can be compiled binaries such as programs written in C and C++, or programs written in scripting languages such as the shell, Perl, Python, Ruby, etc.
- A command built into the shell itself. bash provides a number of commands internally called shell builtins. The cd command, for example, is a shell builtin.
- A shell function. These are miniature shell scripts incorporated into the environment. We will cover configuring the environment and writing shell functions in later lessons, but for now, just be aware that they exist.
- An alias. Commands that you can define yourselves, built from other commands. This will be covered in a later lesson.
F. I/O redirection
most command line programs that display their results do so by sending their results to a facility called standards output.
“>” character is used to send the output to a designated file
“>>” character is used to append the output, single “>” overwrites the previous data of the file.
$((arithmetic expression))
ex. Echo $(($((5 ** 2))* 3)) or
$(((5 ** 2) * 3))
Brace Expression
mkdir {2007..2009}-0{1..9} {2007..2009}-{10..12}
$ echo a{A{1,2},B{3,4}}b
aA1b aA2b aB3b aB4b
G. Permissions
computing systems can have not only multitasking but also multi-user. Before computers were personal, a typical university computer system consisted of a large mainframe computer and terminals were located throughout the campus.
1. Chmod - modify file accès rights
when ls -l is typed, -rwxrwxrwx type format may appear. The first case is displayed as - or d, - for file d for directory. there are three sections divided by three letters, each part in sequential order representing owner, group owner, and other users.
chmod ### file/directory will modify the access rights.
the numbers are represented as binary. for rwx, it will be 111 = 7. So if you want to grant all access to all users, which is not recommended, you have to type 777.
2. Su - temporarily become the superuser
you can become the superuser by typing the command su. Typing exit will end your superuser session.
on apple though, su is disabled by default, I have enabled the su command using the taewon default password.
3. Sudo - temporarily become the superuser
4. Chown - change file ownership
5. Chgrp - change a file’s group ownership
H. Job Control
**cannot perform this on Mac OS, have to get back to it once I install linux os**
a single processor computer can only execute one process t a time but the linux kernel manages to give each process its turn so it makes it look like it is running simultaneously.
1. Ps - list the processes running on the system
2. Kill - send a signal to one or more processes (usually to kill a process)
3. Jobs - an alternate way of listing your own processes
4. Bg - put a process in the background
5. Fg - put a process in the foreground
'IT > ETC' 카테고리의 다른 글
FileZilla connect using .ppk(01/31/20 cudo notes2) (0) | 2020.01.31 |
---|---|
Writing Shell script 1 (0) | 2020.01.30 |
Setting aws ec2 and rds, install java jdk8 on ec2(1/30/20 cudo notes1) (0) | 2020.01.30 |
UnsupportedClassVersionError (0) | 2020.01.29 |
FTP vs SFTP (0) | 2020.01.29 |