1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,275 @@ |
1 |
+--- |
|
2 |
+title: 'How to Use FX700' |
|
3 |
+taxonomy: |
|
4 |
+ category: |
|
5 |
+ - docs |
|
6 |
+external_links: |
|
7 |
+ process: true |
|
8 |
+ no_follow: true |
|
9 |
+ target: _blank |
|
10 |
+ mode: active |
|
11 |
+media_order: fx700_system.png |
|
12 |
+published: true |
|
13 |
+--- |
|
14 |
+ |
|
15 |
+[toc] |
|
16 |
+ |
|
17 |
+## Overview {#overview} |
|
18 |
+ |
|
19 |
+PRIMEHPC FX700 is the latest supercomputer equipped with the same CPU as Fugaku. |
|
20 |
+ACCMS has an FX700 in a small configuration and provides it as an evaluation environment for users of the supercomputer system. |
|
21 |
+ |
|
22 |
+Please apply for the [Application Form for Collaborative Research Project for FX700 "Trial Use" and "Small Node Use"](http://www.iimc.kyoto-u.ac.jp/ja/services/comp/support/kyodo/fx700_2021.html) to use this service. The trial use allows you to use the FX700 for one month without any screening. There is no cost burden for use. |
|
23 |
+ |
|
24 |
+! The job scheduler has been changed from PBS to Slurm from April 2023. |
|
25 |
+ |
|
26 |
+## System Configuration {#system} |
|
27 |
+ |
|
28 |
+It is a configuration of a small PC cluster type connected to a network independent of Camphor3 and Laurel3. |
|
29 |
+The login node is a server on an Intel Xeon processor (x86_64 architecture), so cross-compilation is required to run the program on A64FX processor (aarch64 architecture) of the computing node. For convenience, the configuration allows interactive native compilation even on a computing node fx-0001. |
|
30 |
+ |
|
31 |
+![fx700_system](fx700_system.png?lightbox=100%&resize=600 "fx700_system") |
|
32 |
+ |
|
33 |
+Computing Node CPU Specifications |
|
34 |
+ |
|
35 |
+| Item | Description |
|
36 |
+| ------------ | -------------- |
|
37 |
+| Name | A64FX |
|
38 |
+| Command | Set |
|
39 |
+| Architecture | Armv8.2-A SVE |
|
40 |
+| Number of computing cores | 48 cores |
|
41 |
+| Clock | 1.8 GHz |
|
42 |
+| Theoretical computing performance | 2.7648 TFLOPS |
|
43 |
+ |
|
44 |
+Computing node specifications |
|
45 |
+ |
|
46 |
+| Item | Description |
|
47 |
+| ------------ | -------------- |
|
48 |
+| Architecture | 1 CPU/node |
|
49 |
+| Memory capacity | 32 GiB(HBM2, 4 stack) |
|
50 |
+| Memory Bandwidths | 1,024 GB/s |
|
51 |
+| Interconnects | InfiniBand EDR |
|
52 |
+| Internal storage | M.2 SSD Type 2280 slot(NVMe) |
|
53 |
+| OS | Red Hat Enterprise Linux 8 |
|
54 |
+ |
|
55 |
+[PRIMEHPC FX700 Product Information](https://www.fujitsu.com/jp/products/computing/servers/supercomputer/downloads/#anc-fx700) |
|
56 |
+ |
|
57 |
+ |
|
58 |
+### Login Nodes {#login} |
|
59 |
+ |
|
60 |
+To log in to the FX700, connect to the following hosts via SSH public key authentication |
|
61 |
+ |
|
62 |
+``` |
|
63 |
+fx-login.kudpc.kyoto-u.ac.jp |
|
64 |
+``` |
|
65 |
+ - You can log in with the key you have already registered in the user portal of the supercomputer. (Keys added directly to authorized_keys in the Camphor3 and Laurel3 home directories will not be available.) |
|
66 |
+ - Inside the cluster, mutual login is possible with host-based authentication. |
|
67 |
+ |
|
68 |
+### Shared Storage {#storage} |
|
69 |
+ |
|
70 |
+/home and /work are configured as shared storage. Since /home is a local storage of fx-login, the response to operations on the login node is fast but it is not strong enough for the load. Please use /work to perform calculations. |
|
71 |
+ |
|
72 |
+```bash |
|
73 |
+[root@fx-0001 ~]# df -h /home/ /work/ |
|
74 |
+Filesystem Size Used Avail Use% Mounted on |
|
75 |
+fx-login-ib:/home 399G 27G 373G 7% /home |
|
76 |
+armst-ib:/work 7.0T 25G 7.0T 1% /work |
|
77 |
+``` |
|
78 |
+ - /home mounts fx-login:/home. **20GB capacity limit per user.** |
|
79 |
+ - /work mounts armst:/work. Please use this for calculations. **500GB capacity limit per user.** |
|
80 |
+ - /home and /work are mounted each time they are accessed by autofs. |
|
81 |
+ - If /work capacity is insufficient, please contact us. |
|
82 |
+ - If the file server is not responding, please notify the administrator. We will restart the file server side. |
|
83 |
+ - Files will be deleted after the end of the service, please make your own backups during the period of use. |
|
84 |
+ |
|
85 |
+## How to compile {#compile} |
|
86 |
+ |
|
87 |
+Available compilers are Fujitsu compiler and GCC. |
|
88 |
+ |
|
89 |
+### Fujitsu Compiler {#fujitsu-compiler} |
|
90 |
+ |
|
91 |
+**Commands for cross-compilation in fx-login** |
|
92 |
+```bash |
|
93 |
+# For fortran |
|
94 |
+[b12345@fx-login ~]$ frtpx -v |
|
95 |
+frtpx: Fujitsu Fortran Compiler 4.4.0 |
|
96 |
+How to Use: frtpx [Option] File |
|
97 |
+ |
|
98 |
+[b12345@fx-login ~]$ mpifrtpx -v |
|
99 |
+frtpx: Fujitsu Fortran Compiler 4.4.0 |
|
100 |
+How to Use: frtpx [Option] File |
|
101 |
+ |
|
102 |
+# For C Language |
|
103 |
+[b12345@fx-login ~]$ fccpx -v |
|
104 |
+fccpx: Fujitsu C/C++ Compiler 4.4.0 |
|
105 |
+simulating gcc version 6.1 |
|
106 |
+ |
|
107 |
+[b12345@fx-login ~]$ mpifccpx -v |
|
108 |
+fccpx: Fujitsu C/C++ Compiler 4.4.0 |
|
109 |
+simulating gcc version 6.1 |
|
110 |
+How to Use: fccpx [Option] File |
|
111 |
+ |
|
112 |
+# For C++ Language |
|
113 |
+[b12345@fx-login ~]$ FCCpx -v |
|
114 |
+FCCpx: Fujitsu C/C++ Compiler 4.4.0 |
|
115 |
+simulating gcc version 6.1 |
|
116 |
+How to Use: FCCpx [Option] File |
|
117 |
+ |
|
118 |
+[b12345@fx-login ~]$ mpiFCCpx -v |
|
119 |
+FCCpx: Fujitsu C/C++ Compiler 4.4.0 |
|
120 |
+simulating gcc version 6.1 |
|
121 |
+How to Use: FCCpx [Option] File |
|
122 |
+``` |
|
123 |
+ |
|
124 |
+**Commands for native compilation in fx-0001** |
|
125 |
+```bash |
|
126 |
+# For fortran |
|
127 |
+[b12345@fx-0001 ~]$ frt -v |
|
128 |
+frt: Fujitsu Fortran Compiler 4.4.0 |
|
129 |
+How to Use: frt [Option] File |
|
130 |
+ |
|
131 |
+[b12345@fx-0001 ~]$ mpifrt -v |
|
132 |
+frt: Fujitsu Fortran Compiler 4.4.0 |
|
133 |
+How to Use: frt [Option] File |
|
134 |
+ |
|
135 |
+# For C Language |
|
136 |
+[b12345@fx-0001 ~]$ fcc -v |
|
137 |
+fcc: Fujitsu C/C++ Compiler 4.4.0 |
|
138 |
+simulating gcc version 6.1 |
|
139 |
+How to Use: fcc [Option] File |
|
140 |
+ |
|
141 |
+[b12345@fx-0001 ~]$ mpifcc -v |
|
142 |
+fcc: Fujitsu C/C++ Compiler 4.4.0 |
|
143 |
+simulating gcc version 6.1 |
|
144 |
+How to Use: fcc [Option] File |
|
145 |
+ |
|
146 |
+# For C++Language |
|
147 |
+[b12345@fx-0001 ~]$ FCC -v |
|
148 |
+FCC: Fujitsu C/C++ Compiler 4.4.0 |
|
149 |
+simulating gcc version 6.1 |
|
150 |
+How to Use: FCC [Option] File |
|
151 |
+ |
|
152 |
+[b12345@fx-0001 ~]$ mpiFCC -v |
|
153 |
+FCC: Fujitsu C/C++ Compiler 4.4.0 |
|
154 |
+simulating gcc version 6.1 |
|
155 |
+How to Use: FCC [Option] File |
|
156 |
+``` |
|
157 |
+ |
|
158 |
+Typical compile options |
|
159 |
+ |
|
160 |
+| Option Name | Description |
|
161 |
+| ------------ | -------------- |
|
162 |
+| -Kopenmp |Compile with OpenMP directive enabled. |
|
163 |
+| -Kparallel | Enable automatic parallelization. |
|
164 |
+| -Kfast | Create object programs that run at high speed on the target machine. -O3 -Keval,fast_matmul,fp_contract,fp_relaxed,fz,ilfunc,mfunc,omitfp,simd_packed_promotion と等価です。 |
|
165 |
+| -KA64FX | Indicate the program to output an object file for the A64FX processor. |
|
166 |
+| -KSVE | Indicate whether or not to use SVE, an extension of the Armv8-A architecture. |
|
167 |
+ |
|
168 |
+ Please refer to the manual for details on the compiler. |
|
169 |
+ |
|
170 |
+[Fujitsu Compiler Manual](https://web.kudpc.kyoto-u.ac.jp/auth/manual/fcomp/lastest) |
|
171 |
+(Access requires authentication with a supercomputer login account) |
|
172 |
+ |
|
173 |
+### GCC |
|
174 |
+ |
|
175 |
+Compile natively on fx-0001. |
|
176 |
+```bash |
|
177 |
+[b12345@fx-0001 ~]$ gfortran --version |
|
178 |
+GNU Fortran (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5) |
|
179 |
+Copyright (C) 2018 Free Software Foundation, Inc. |
|
180 |
+This is free software; see the source for copying conditions. There is NO |
|
181 |
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
182 |
+ |
|
183 |
+[b12345@fx-0001 ~]$ gcc --version |
|
184 |
+gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5) |
|
185 |
+Copyright (C) 2018 Free Software Foundation, Inc. |
|
186 |
+This is free software; see the source for copying conditions. There is NO |
|
187 |
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
188 |
+ |
|
189 |
+[b12345@fx-0001 ~]$ g++ --version |
|
190 |
+g++ (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5) |
|
191 |
+Copyright (C) 2018 Free Software Foundation, Inc. |
|
192 |
+This is free software; see the source for copying conditions. There is NO |
|
193 |
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
194 |
+``` |
|
195 |
+ |
|
196 |
+ |
|
197 |
+## How to Submit Jobs (Slurm) {#job} |
|
198 |
+ |
|
199 |
+Please submit your job with the sbatch command. Please note that the writing method of the job script is different from Camphor3 and Laurel3. Camphor3 and Laurel3 customize Slurm to their own specifications, while FX700 uses only standard Slurm features. |
|
200 |
+ |
|
201 |
+ |
|
202 |
+### Batch Queues {#queue} |
|
203 |
+ |
|
204 |
+There is a debug queue assigned only one node and a short queue assigned 10 nodes. |
|
205 |
+After testing in the debug queue, run the job in the short queue. |
|
206 |
+ |
|
207 |
+```bash |
|
208 |
+$ sinfo -s |
|
209 |
+PARTITION AVAIL TIMELIMIT NODES(A/I/O/T) NODELIST |
|
210 |
+debug* up infinite 2/7/2/11 fx-[0002-0012] |
|
211 |
+short up infinite 2/7/2/11 fx-[0002-0012] |
|
212 |
+``` |
|
213 |
+ |
|
214 |
+### Option |
|
215 |
+|Option|Description|Initial Value|Maximum Value| |
|
216 |
+|----------|----|------|------| |
|
217 |
+|#SBATCH -p _QUEUE_ | Specify queue name | -- | -- | |
|
218 |
+|#SBATCH -N _NODE_ |Specify the number of nodes to use|1|Trial Use:1 / Small Node Use:8| |
|
219 |
+|#SBATCH -n _PROCS_ |Specify the number of processes|1|Trial Use:48 / Small Node Use:384| |
|
220 |
+|#SBATCH --cpus-per-task=_CORES_|Specify the number of cores per process|1|48| |
|
221 |
+|#SBATCH --mem=_MEMORY_|Specify the memory size per process|650M|31200M| |
|
222 |
+|#SBATCH -t _HOUR_:_MINUTES_:_SECONDS_ | Specify upper limit of the execution time | 1:00:00(1 hour) | 168:0:0(7 days)| |
|
223 |
+ |
|
224 |
+### Example of Job Script Description{#jobscript} |
|
225 |
+ |
|
226 |
+Example 1 of Job Scripts (Sequential jobs with 1 core and 8 GB secured) |
|
227 |
+```bash |
|
228 |
+#!/bin/bash |
|
229 |
+#SBATCH -p debug |
|
230 |
+#SBATCH -N 1 # Number of nodes |
|
231 |
+#SBATCH -n 8 # Number of processes |
|
232 |
+#SBATCH --cpus-per-task=1 # Number of cores per process |
|
233 |
+#SBATCH --mem=8G # Memory size per node |
|
234 |
+ |
|
235 |
+srun ./a.out |
|
236 |
+``` |
|
237 |
+ |
|
238 |
+Example 2 of Job Scripts (OpenMP job (16 threads) with 16 cores and 8 GB secured) |
|
239 |
+```bash |
|
240 |
+#!/bin/bash |
|
241 |
+#SBATCH -p debug |
|
242 |
+#SBATCH -N 1 # Number of nodes |
|
243 |
+#SBATCH -n 1 # Number of processes |
|
244 |
+#SBATCH --cpus-per-task=16 # Number of cores per process |
|
245 |
+#SBATCH --mem=8G # Memory size per node |
|
246 |
+#SBATCH -t 1:00:00 # Upper limit of elapsed time 1 hour |
|
247 |
+ |
|
248 |
+srun ./a.out |
|
249 |
+``` |
|
250 |
+ |
|
251 |
+Example 3 of Job Scripts ((48 cores, 8GB memory) x MPI job of 2 nodes (96 processes)) |
|
252 |
+```bash |
|
253 |
+#!/usr/bin/bash |
|
254 |
+#SBATCH -p debug |
|
255 |
+#SBATCH -N 2 # Number of nodes |
|
256 |
+#SBATCH -n 96 # Number of processes |
|
257 |
+#SBATCH --cpus-per-task=1 # Number of cores per process |
|
258 |
+#SBATCH --mem=30G # Memory size per node |
|
259 |
+#SBATCH -t 1:00:00 # Upper limit of elapsed time 1 hour |
|
260 |
+ |
|
261 |
+srun ./a.out |
|
262 |
+``` |
|
263 |
+ |
|
264 |
+Example 4 of Job Scripts ((48 cores, 30GB memory) x hybrid job of 2 nodes (24 processes x 4 threads)) |
|
265 |
+```bash |
|
266 |
+#!/bin/bash |
|
267 |
+#SBATCH -p debug |
|
268 |
+#SBATCH -N 2 # Number of nodes |
|
269 |
+#SBATCH -n 24 # Number of processes |
|
270 |
+#SBATCH --cpus-per-task=4 # Number of cores per process |
|
271 |
+#SBATCH --mem=30G # Memory size per node |
|
272 |
+#SBATCH -t 1:00:00 # Upper limit of elapsed time 1 hour |
|
273 |
+ |
|
274 |
+srun ./a.out |
|
275 |
+``` |
... | ... |
@@ -1,765 +1,766 @@ |
1 |
-title: 'Unix/Linux Basics' |
|
2 |
-taxonomy: |
|
3 |
- category: |
|
4 |
- - docs |
|
5 |
- |
|
6 |
-[toc] |
|
7 |
- |
|
8 |
- |
|
9 |
-## File System{#system} |
|
10 |
- |
|
11 |
- |
|
12 |
-### File and Directory{#file} |
|
13 |
- |
|
14 |
-Various types of data that users create on UNIX are recorded as **files** , and be stored in containers that called **directories** . You can create a directory in a directory recursively, you can manage files hierarchically. |
|
15 |
- |
|
16 |
-![](348_901.jpeg) |
|
17 |
- |
|
18 |
-This file structure is called the tree structure because it looks like a tree with branches. In UNIX, the root of the tree is called the **root directory** and denoted by “/ (slash).” The directory that a user is working is called the **current directory**. |
|
19 |
- |
|
20 |
- |
|
21 |
-### Absolute Path and Relative Path{#path} |
|
22 |
- |
|
23 |
-The concept the **path** is needed to specify a file on the tree structure. You can specify a file in two methods: **absolute path** and **relative path**. |
|
24 |
- |
|
25 |
-* **Absolute path method** |
|
26 |
- |
|
27 |
-The method is to specify a file relative to the root directory. |
|
28 |
- |
|
29 |
-**Example**: the case of specifying the “report1.txt” in Figure 1. |
|
30 |
- |
|
31 |
- |
|
32 |
-```nohighlight |
|
33 |
-/home/a/b59999/report/report1.txt |
|
34 |
-``` |
|
35 |
- |
|
36 |
- |
|
37 |
-* **Relative path method** |
|
38 |
- |
|
39 |
-The method is to specify a file relative to the current directory. |
|
40 |
- |
|
41 |
-**Example**: the case of specifying the “report1.txt” in Figure 1 relative to the current directory “/home/a/b59999.” |
|
42 |
- |
|
43 |
- |
|
44 |
-```nohighlight |
|
45 |
-report/report1.txt |
|
46 |
-``` |
|
47 |
- |
|
48 |
- |
|
49 |
- |
|
50 |
-## Basic Commands {#command} |
|
51 |
- |
|
52 |
- |
|
53 |
-### `pwd` – Command for Displaying Current Directory{#pwd} |
|
54 |
- |
|
55 |
- |
|
56 |
-```nohighlight |
|
57 |
-pwd |
|
58 |
-``` |
|
59 |
- |
|
60 |
- |
|
61 |
-**Example** |
|
62 |
- |
|
63 |
- |
|
64 |
-```nohighlight |
|
65 |
-[b59999@hx001 ~]$ pwd |
|
66 |
-``` |
|
67 |
- |
|
68 |
-```nohighlight |
|
69 |
-/home/a/b59999 # The current directory is displayed |
|
70 |
-``` |
|
71 |
- |
|
72 |
- |
|
73 |
- |
|
74 |
-### `ls` – Command for Displaying File List{#ls} |
|
75 |
- |
|
76 |
- |
|
77 |
-```nohighlight |
|
78 |
-ls [option] [filename] [directory] |
|
79 |
-``` |
|
80 |
- |
|
81 |
- |
|
82 |
-**Important Command Line Options** |
|
83 |
- |
|
84 |
-Option | Effect |
|
85 |
- -l | Displays details of files |
|
86 |
- -F | “/“ is appended to directories and “*” is appended to executables to make file types clear in the display |
|
87 |
- -a | Files whose names starts with “.”, those for system use, are also displayed. |
|
88 |
- |
|
89 |
- |
|
90 |
- |
|
91 |
-**Example** |
|
92 |
- |
|
93 |
- |
|
94 |
-```nohighlight |
|
95 |
-[b59999@hx001 ~]$ ls |
|
96 |
-``` |
|
97 |
- |
|
98 |
-```nohighlight |
|
99 |
-file1.txt file2.bmp dir1 # A filename is displayed |
|
100 |
-[b59999@hx001 ~]$ ls -a |
|
101 |
-``` |
|
102 |
- |
|
103 |
-```nohighlight |
|
104 |
-. .cshrc .tcshrc file1.txt dir1 # Filenames starting with “.” are also displayed |
|
105 |
-.. .login .bashrc file2.bmp |
|
106 |
-[b59999@hx001 ~]$ ls -F |
|
107 |
-``` |
|
108 |
- |
|
109 |
-```nohighlight |
|
110 |
-file1.txt file2.bmp dir1/ # "/" is appended to a directory |
|
111 |
-[b59999@hx001 ~]$ |
|
112 |
-``` |
|
113 |
- |
|
114 |
- |
|
115 |
- |
|
116 |
-### `cd` – Command for Changing Current Directory{#cd} |
|
117 |
- |
|
118 |
- |
|
119 |
-```nohighlight |
|
120 |
-cd [directory_name] |
|
121 |
-``` |
|
122 |
- |
|
123 |
- |
|
124 |
-**Example** |
|
125 |
- |
|
126 |
- |
|
127 |
-```nohighlight |
|
128 |
-[b59999@hx001 ~]$ pwd |
|
129 |
-``` |
|
130 |
- |
|
131 |
-```nohighlight |
|
132 |
-/home/a/b59999 # The current directory is /home/a/b59999 |
|
133 |
-``` |
|
134 |
- |
|
135 |
-```nohighlight |
|
136 |
-[b59999@hx001 ~]$ cd dir1 # Changing the current directory to dir1 |
|
137 |
-[b59999@hx001 ~]$ pwd |
|
138 |
-``` |
|
139 |
- |
|
140 |
-```nohighlight |
|
141 |
-/home/a/b59999/dir1 # The current directory has been changed to dir1 |
|
142 |
-``` |
|
143 |
- |
|
144 |
- |
|
145 |
- |
|
146 |
-### `cp` – Command for Copying Files and Directories{#cp} |
|
147 |
- |
|
148 |
- |
|
149 |
-```nohighlight |
|
150 |
-cp [options] [copy_source] [copy_destination] |
|
151 |
-``` |
|
152 |
- |
|
153 |
- |
|
154 |
-**Important command line options** |
|
155 |
- |
|
156 |
-Option | Effect |
|
157 |
- -R | If the copy source is a directory, the entire tree structure under and including the directory is copied. |
|
158 |
- |
|
159 |
- |
|
160 |
- |
|
161 |
-**Example** |
|
162 |
- |
|
163 |
- |
|
164 |
-```nohighlight |
|
165 |
-[b59999@hx001 ~]$ ls -F |
|
166 |
-file1.txt dir1/ |
|
167 |
-``` |
|
168 |
- |
|
169 |
-```nohighlight |
|
170 |
-[b59999@hx001 ~]$ cp file1.txt file2.txt # Copying file1.txt as file2.txt |
|
171 |
-[b59999@hx001 ~]$ ls -F |
|
172 |
-``` |
|
173 |
- |
|
174 |
-```nohighlight |
|
175 |
-file1.txt file2.bmp dir1/ # file2.txt has been created |
|
176 |
-``` |
|
177 |
- |
|
178 |
-```nohighlight |
|
179 |
-[b59999@hx001 ~]$ cp file2.txt dir1 # Copying file2.txt to dir1 |
|
180 |
-[b59999@hx001 ~]$ ls dir1 |
|
181 |
-``` |
|
182 |
- |
|
183 |
-```nohighlight |
|
184 |
-file2.txt # file2.txt has been copied to dir1 |
|
185 |
-``` |
|
186 |
- |
|
187 |
-```nohighlight |
|
188 |
-[b59999@hx001 ~]$ cp -R dir1 dir2 # dir1 is copied to dir2 |
|
189 |
-[b59999@hx001 ~]$ ls -F |
|
190 |
-``` |
|
191 |
- |
|
192 |
-```nohighlight |
|
193 |
-file1.txt file2.txt dir1/ dir2/ # dir2 has been created |
|
194 |
-[b59999@hx001 ~]$ ls dir2 |
|
195 |
-``` |
|
196 |
- |
|
197 |
-```nohighlight |
|
198 |
-file2.txt # dir1 has been copied to dir2 including the tree structure |
|
199 |
-[b59999@hx001 ~]$ |
|
200 |
-``` |
|
201 |
- |
|
202 |
- |
|
203 |
- |
|
204 |
-### `mkdir` – Command for Making New Directories{#mkdir} |
|
205 |
- |
|
206 |
- |
|
207 |
-```nohighlight |
|
208 |
-mkdir [directory_name] |
|
209 |
-``` |
|
210 |
- |
|
211 |
- |
|
212 |
-**Example** |
|
213 |
- |
|
214 |
- |
|
215 |
-```nohighlight |
|
216 |
-[b59999@hx001 ~]$ ls |
|
217 |
-file1.txt file2.bmp |
|
218 |
-[b59999@hx001 ~]$ mkdir dir1 |
|
219 |
-[b59999@hx001 ~]$ ls -F |
|
220 |
-``` |
|
221 |
- |
|
222 |
-```nohighlight |
|
223 |
-file1.txt file2.bmp dir1/ # dir1 has been created |
|
224 |
-[b59999@hx001 ~]$ |
|
225 |
-``` |
|
226 |
- |
|
227 |
- |
|
228 |
- |
|
229 |
-### `rm` – Command for Deleting Files and Directories{#rm} |
|
230 |
- |
|
231 |
- |
|
232 |
-```nohighlight |
|
233 |
-rm [option] [filename] [directory] |
|
234 |
-``` |
|
235 |
- |
|
236 |
- |
|
237 |
-**Important command line options** |
|
238 |
- |
|
239 |
-Option | Effect |
|
240 |
- -R | If the target is a directory, the entire tree structure under and including the directory is deleted. |
|
241 |
- |
|
242 |
-**Example** |
|
243 |
- |
|
244 |
- |
|
245 |
-```nohighlight |
|
246 |
-[b59999@hx001 ~]$ ls -F |
|
247 |
-file1.txt file2.bmp dir1/ |
|
248 |
-``` |
|
249 |
- |
|
250 |
-```nohighlight |
|
251 |
-[b59999@hx001 ~]$ rm file1.txt # Deleting file1.txt |
|
252 |
-[b59999@hx001 ~]$ ls -F |
|
253 |
-``` |
|
254 |
- |
|
255 |
-```nohighlight |
|
256 |
-file2.bmp dir1/ # file1.txt has been deleted |
|
257 |
-[b59999@hx001 ~]$ ls -F dir1 |
|
258 |
-``` |
|
259 |
- |
|
260 |
-```nohighlight |
|
261 |
-dir2/ # dir2 is under dir1 |
|
262 |
-``` |
|
263 |
- |
|
264 |
-```nohighlight |
|
265 |
-[b59999@hx001 ~]$ rm -R dir1 # Deleting dir1 |
|
266 |
-[b59999@hx001 ~]$ ls -F |
|
267 |
-``` |
|
268 |
- |
|
269 |
-```nohighlight |
|
270 |
-file2.bmp # dir1 and its tree structure are deleted |
|
271 |
-``` |
|
272 |
- |
|
273 |
- |
|
274 |
- |
|
275 |
-### `mv` – Command for Moving Files (for Changing Filenames){#mv} |
|
276 |
- |
|
277 |
-The mv command is used to move files and directories. This command can also be used to changing the filename, by moving a file to the same directory. |
|
278 |
- |
|
279 |
- |
|
280 |
-```nohighlight |
|
281 |
-mv [source_filename] [new_filename] |
|
282 |
-``` |
|
283 |
- |
|
284 |
- |
|
285 |
-**Example** |
|
286 |
- |
|
287 |
- |
|
288 |
-```nohighlight |
|
289 |
-[b59999@hx001 ~]$ ls -F |
|
290 |
-file1.txt file2.bmp dir1/ |
|
291 |
-``` |
|
292 |
- |
|
293 |
-```nohighlight |
|
294 |
-[b59999@hx001 ~]$ mv file1.txt dir1 # Moving file1.txt to dir1 |
|
295 |
-[b59999@hx001 ~]$ ls -F |
|
296 |
-``` |
|
297 |
- |
|
298 |
-```nohighlight |
|
299 |
-file2.bmp dir1/ # file1.txt no longer exists |
|
300 |
-[b59999@hx001 ~]$ ls dir1 |
|
301 |
-``` |
|
302 |
- |
|
303 |
-```nohighlight |
|
304 |
-file1.txt # Moved to dir1 |
|
305 |
-``` |
|
306 |
- |
|
307 |
-```nohighlight |
|
308 |
-[b59999@hx001 ~]$ mv file2.bmp file3.bmp # Moving file2.bmp to file3.bmp |
|
309 |
-[b59999@hx001 ~]$ ls -F |
|
310 |
-``` |
|
311 |
- |
|
312 |
-```nohighlight |
|
313 |
-file3.bmp dir1/ # The filename has been changed to file3.bmp |
|
314 |
-``` |
|
315 |
- |
|
316 |
- |
|
317 |
- |
|
318 |
-### `cat` – Command for Displaying File Contents on Screen{#cat} |
|
319 |
- |
|
320 |
- |
|
321 |
-```nohighlight |
|
322 |
-cat [filename] |
|
323 |
-``` |
|
324 |
- |
|
325 |
- |
|
326 |
-**Example** |
|
327 |
- |
|
328 |
- |
|
329 |
-```nohighlight |
|
330 |
-[b59999@hx001 ~]$ ls -F |
|
331 |
-file1.txt file2.bmp dir1/ |
|
332 |
-[b59999@hx001 ~]$ cat file1.txt |
|
333 |
-``` |
|
334 |
- |
|
335 |
-```nohighlight |
|
336 |
-abcdefghijklmnopqrstuvwxyz # The content of file1.txt is shown |
|
337 |
-[b59999@hx001 ~]$ |
|
338 |
-``` |
|
339 |
- |
|
340 |
- |
|
341 |
- |
|
342 |
-### `more` and `less` – Commands for Displaying File Contents{#less} |
|
343 |
- |
|
344 |
-By using the more command and the less command instead of the cat command stops and waits for the next command after displaying each page in the case of a large file. |
|
345 |
- |
|
346 |
- |
|
347 |
-```nohighlight |
|
348 |
-more (or less) [filename] |
|
349 |
-``` |
|
350 |
- |
|
351 |
- |
|
352 |
-**Example** |
|
353 |
- |
|
354 |
- |
|
355 |
-```nohighlight |
|
356 |
-[b59999@hx001 ~]$ more file3.c |
|
357 |
-#include <stdio.h> /* The content of file3.c is shown */ |
|
358 |
-#include <math.h> |
|
359 |
-#include <stdlib.h> |
|
360 |
-(…omission...) |
|
361 |
- for(i=0; i<10; i++){ |
|
362 |
- a[i] = b[i]*c[i]; |
|
363 |
- Pressing the space key advances the display one page. |
|
364 |
-``` |
|
365 |
- |
|
366 |
- |
|
367 |
- |
|
368 |
-### `logout` – Command for Logout{#logout} |
|
369 |
- |
|
370 |
- |
|
371 |
-```nohighlight |
|
372 |
-logout |
|
373 |
-``` |
|
374 |
- |
|
375 |
- |
|
376 |
-**Example** |
|
377 |
- |
|
378 |
- |
|
379 |
- |
|
380 |
-```nohighlight |
|
381 |
-[b59999@hx001 ~]$ logout # Logging out |
|
382 |
-``` |
|
383 |
- |
|
384 |
- |
|
385 |
- |
|
386 |
-### `man` – Command for Viewing Manual of Commands{#man} |
|
387 |
- |
|
388 |
-**Example: displaying the explanation of the ls command** |
|
389 |
- |
|
390 |
- |
|
391 |
-```nohighlight |
|
392 |
-[b59999@hx001 ~]$ man ls |
|
393 |
-``` |
|
394 |
- |
|
395 |
- |
|
396 |
-To display man command messages in English, the environment variable LANG to C. |
|
397 |
- |
|
398 |
-**In the case of tcsh** |
|
399 |
- |
|
400 |
- |
|
401 |
-```nohighlight |
|
402 |
-[b59999@hx001 ~]$ setenv LANG C |
|
403 |
-``` |
|
404 |
- |
|
405 |
- |
|
406 |
-**In the case of bash** |
|
407 |
- |
|
408 |
- |
|
409 |
-```nohighlight |
|
410 |
-[b59999@hx001 ~]$ export LANG=C |
|
411 |
-``` |
|
412 |
- |
|
413 |
- |
|
414 |
- |
|
415 |
-## How to Use vi Editor{#vi} |
|
416 |
- |
|
417 |
-A UNIX family OS includes the vi Editor as standard. The vi Editor has an unique operational architecture, we explain in detail below. |
|
418 |
- |
|
419 |
-**How to Start vi Editor** |
|
420 |
- |
|
421 |
- |
|
422 |
-```nohighlight |
|
423 |
-vi [filename] |
|
424 |
-``` |
|
425 |
- |
|
426 |
- |
|
427 |
-**Two Modes of vi Editor** |
|
428 |
- |
|
429 |
-The vi editor has two modes. |
|
430 |
- |
|
431 |
-* **Command mode** |
|
432 |
- |
|
433 |
-You make operations other than entering characters such as searching, replacing, saving a file, |
|
434 |
-and deleting a character or a line. |
|
435 |
- |
|
436 |
-* **Edit mode** |
|
437 |
- |
|
438 |
-you enter characters. |
|
439 |
- |
|
440 |
-The vi editor starts in the command mode when it opens. To enter the edit mode, press one of the following keys: `i` , `I` , `a` , `A` , `o` , `O` . To return to the command mode from the edit mode, press the ESC key. |
|
441 |
- |
|
442 |
- |
|
443 |
-### vi Command Reference{#vi} |
|
444 |
- |
|
445 |
-**Moving Cursor** |
|
446 |
- |
|
447 |
-Character Oriented Jump |
|
448 |
- h, j, k, l | left, down, up, right (←, ↓, ↑, →) |
|
449 |
- |
|
450 |
-Text Oriented Jump |
|
451 |
- w, W, b, B | Previous/next word |
|
452 |
- e, E | End of word |
|
453 |
- ), ( | Top of previous/next sentence |
|
454 |
- }, { | Top of previous/next paragraph |
|
455 |
- ]], [[ | Top of previous/next section |
|
456 |
- |
|
457 |
-Line Oriented Jump |
|
458 |
- 0 (zero), $ | Beginning/end of current line |
|
459 |
- ^ | First character (other than space) of current line |
|
460 |
- +, – | First character of next/previous line |
|
461 |
-_n_l | _n_’th character of current line |
|
462 |
- H | First line on the screen |
|
463 |
- M | Center line on the screen |
|
464 |
- L | Bottom line on the screen |
|
465 |
-_n_H | _n_’th line from the top |
|
466 |
-_n_L | _n_’th line from the bottom |
|
467 |
- |
|
468 |
-Screen Oriented Jump |
|
469 |
-CTRL + f, CTRL + b | Scroll to next/previous screen |
|
470 |
-CTRL + d, CTRL + u | Scroll downward/upward half screen |
|
471 |
-CTRL + e, CTRL + y | Display another line at the top/bottom of window |
|
472 |
- z RETURN | Show the line of cursor at the top of screen |
|
473 |
- z. (zed dot) | Show the line of cursor at the center of screen |
|
474 |
- z- (zed hyphen) | Show the line of cursor at the bottom of screen |
|
475 |
-CTRL + l, CTRL + r | Refresh screen (no scroll) |
|
476 |
- |
|
477 |
-Search |
|
478 |
- /_pattern_ | Search forward for pattern |
|
479 |
- –_pattern_ | Search backward for pattern |
|
480 |
- n, N | Repeat previous search in the same/opposite direction |
|
481 |
- /, – | Repeat previous search forward/backward |
|
482 |
- f_x_ | Jump forward from cursor position to next _x_ on current line. |
|
483 |
- F_x_ | Jump backward from cursor position to next _x_ on current line. |
|
484 |
- t_x_ | Jump forward from cursor position to the character followed by next _x_ on current line. |
|
485 |
- T_x_ | Jump backward from cursor position to the character following next _x_ on current line. |
|
486 |
- ; | Repeat previous search on current line |
|
487 |
-, | Repeat previous search on current line in opposite direction |
|
488 |
- |
|
489 |
-Jump by Line Number |
|
490 |
-CTRL + g | Display current line number |
|
491 |
-_n_G | Jump to line number _n_ |
|
492 |
- G | Jump to last line of file |
|
493 |
- :_n_ | Jump to line number _n_ |
|
494 |
- |
|
495 |
-Mark Position |
|
496 |
- m_x_ | Mark current position as _x_ |
|
497 |
- ‘_x_ | Jump to _x_ |
|
498 |
- “ | Return to previous mark or to the location prior to a search |
|
499 |
- `_x_ | Jump to start of a line containing _x_ |
|
500 |
- `` | Return to start of previous line containing the mark |
|
501 |
- |
|
502 |
-**Quitting Commands** |
|
503 |
- |
|
504 |
-Quitting Commands |
|
505 |
- ZZ | Quit vi writing (saving) the file |
|
506 |
- :x | Quit vi writing (saving) the file |
|
507 |
- :wq | Quit vi writing (saving) the file |
|
508 |
- :w | Write (save) the file |
|
509 |
- :w! | (Forcibly) write (save) the file |
|
510 |
- :q | Quit editing |
|
511 |
- :q! | Quit editing (canceling all edit) |
|
512 |
- :e! | Return to the version of current file at the time of last write (save) |
|
513 |
- |
|
514 |
-**Editing Commands** |
|
515 |
- |
|
516 |
-Inserting |
|
517 |
- i, a | Append text before/after the cursor |
|
518 |
- I, A | Insert text at beginning/end of line |
|
519 |
- o, O (Capitalized O) | Open a new line for entering text below/above the cursor |
|
520 |
- |
|
521 |
- Change |
|
522 |
- r | Change character |
|
523 |
- cw | Change word |
|
524 |
- cc | Change current line |
|
525 |
- C | Change text from current position to end of line |
|
526 |
- R | Overwrite text |
|
527 |
- s | Replace character with a text |
|
528 |
- S | Replace current line with a text |
|
529 |
- |
|
530 |
-Moving and Deleting |
|
531 |
- x | Delete character |
|
532 |
- X | Delete the character before cursor |
|
533 |
- dw | Delete a word |
|
534 |
- dd | Delete current line |
|
535 |
- D | Delete remainder of line |
|
536 |
- p, P | Paste deleted text after/before cursor |
|
537 |
- “_n_p | Paste the text of deletion buffer number _n_ after cursor (effective for last 9 deletion) |
|
538 |
- |
|
539 |
-Yank |
|
540 |
- yw | Yank (copy) word |
|
541 |
- yy | Yank current line |
|
542 |
- “_a_yy | Yank current line to the buffer named _a_ |
|
543 |
- p, P | Paste yanked text after/before cursor |
|
544 |
- “_a_p | Paste text of buffer “_a_” before cursor |
|
545 |
- |
|
546 |
-Other Commands |
|
547 |
- . (dot) | Repeat the last editing command |
|
548 |
- u, U | Undo the last edition/recover current line |
|
549 |
- j | Concatenate two lines |
|
550 |
- |
|
551 |
-Using ex Command |
|
552 |
- :d | Delete a line |
|
553 |
- :m | Move a line |
|
554 |
- :co, :t | Copy a line |
|
555 |
- /, – | Repeat previous search forward/backward |
|
556 |
- :.,$d | Delete the text from current line to end of file |
|
557 |
- |
|
558 |
- |
|
559 |
-## How to Use Emacs{#emacs} |
|
560 |
- |
|
561 |
- |
|
562 |
-### What is Emacs– {#emacs_top} |
|
563 |
- |
|
564 |
-**Emacs** is a sophisticated highly customizable text editor often used on UNIX family OS. |
|
565 |
-Editing work using **Emacs** consists of reading the target file to the buffer, editing the content, and writing the edited buffer to the target file. In **Emacs** editing work, you can switch between multiple editing files, and each buffer is assigned with a name. The name of the buffer is usually inherited from the name of the target file. |
|
566 |
- |
|
567 |
- |
|
568 |
-### Starting Emacs{#emacs_boot} |
|
569 |
- |
|
570 |
- |
|
571 |
-```nohighlight |
|
572 |
-emacs [filename] |
|
573 |
-``` |
|
574 |
- |
|
575 |
- |
|
576 |
- If a filename is specified, an editing buffer having the same name is created and the file content is read to the buffer. If there is no file to read (the specified file does not exist), the editing buffer becomes empty. If a filename is not specified, an editing buffer named “scratch” is created. |
|
577 |
- |
|
578 |
- |
|
579 |
- |
|
580 |
- |
|
581 |
-### Emacs Screen {#emacs_display} |
|
582 |
- |
|
583 |
-If **Emacs** is executed in an environment with X (a window system), it starts as an X client opening a new window. |
|
584 |
- |
|
585 |
-![](348_902.jpeg) |
|
586 |
- |
|
587 |
-If it is executed in an environment without X, the following screen shows: |
|
588 |
- |
|
589 |
-![](348_903.jpeg) |
|
590 |
- |
|
591 |
-The **Emacs** screen consists of three sections. |
|
592 |
- |
|
593 |
-* **Text window** |
|
594 |
- |
|
595 |
-It is the largest section where input texts are displayed. |
|
596 |
- |
|
597 |
-* **Mode line** |
|
598 |
- |
|
599 |
-It is the black and white reversal line at the bottom of the text window. it shows status of the text window. |
|
600 |
- |
|
601 |
-![](348_904.jpeg) |
|
602 |
- |
|
603 |
-* **Echo line** |
|
604 |
- |
|
605 |
-It is the line below the mode line, and it shows messages of **Emacs**. It is also used to input **Emacs** operations. |
|
606 |
- |
|
607 |
- |
|
608 |
-### Basic Operations of Emacs{#emacs_use} |
|
609 |
- |
|
610 |
-Operations such as moving cursor are done by special key input. There are two ways of special key input as below. |
|
611 |
- |
|
612 |
-* Entering a character key with the CTRL key pressed down (in this page, this is denoted as **C-[character_key]** ). |
|
613 |
-* Entering a character key after pressing the ESC key and then releasing it (in this page, this is denoted as **M-[character_key]** ). |
|
614 |
- |
|
615 |
-**<ins>Opening a file ( <code>C-x</code> <code>C-f</code> )</ins>** |
|
616 |
- |
|
617 |
-To read a file to a buffer after opening **Emacs**, enter `C-x` `C-f` (enter x with CTRL pressed then enter f with CTRL pressed) on the keyboard, and you see the following message on the echo line. |
|
618 |
- |
|
619 |
- |
|
620 |
-```nohighlight |
|
621 |
-Find file: ~/ |
|
622 |
-``` |
|
623 |
- |
|
624 |
- |
|
625 |
-If you did not start the **Emacs** at the home directory, the path of the current directory is shown instead of ~/. Enter the name of the file you want to edit (“test.txt” in this example) next to the message, and press the Enter key. |
|
626 |
- |
|
627 |
- |
|
628 |
-```nohighlight |
|
629 |
-Find file: ~/test.txt |
|
630 |
-``` |
|
631 |
- |
|
632 |
- |
|
633 |
-A buffer named test.txt is created, and the content of the file is read to the buffer. If the file does not exist, a message (New file) is shown on the echo line. |
|
634 |
- |
|
635 |
-![](348_905.jpeg) |
|
636 |
- |
|
637 |
-**<ins>Entering Text</ins>** |
|
638 |
- |
|
639 |
-Characters are input at the cursor position of the text window by typing them on the keyboard. To delete character, press the Delete key, not the Backspace key. |
|
640 |
- |
|
641 |
-**<ins>Japanese Input System</ins>** |
|
642 |
- |
|
643 |
-To enter Japanese text, you need to start a Japanese input system, by entering C-\(\ [backslash] with CTRL pressed). When the system is started, [あ] will be displayed in the left of the mode line, and the roman-letter-to-kana conversion will be available. To switch off the system, press C-\ again. |
|
644 |
- |
|
645 |
-Typing “kyoutodaigaku”on the keyboard displays the following characters converted from the romaji. |
|
646 |
- |
|
647 |
- |
|
648 |
-```nohighlight |
|
649 |
-| きょうとだいがく | |
|
650 |
-``` |
|
651 |
- |
|
652 |
- |
|
653 |
-The vertical bars “|” on the both sides indicate that characters in between can be converted to kanji characters. Pressing the Space key to convert into kanji. The mark at the left corner is changed from [あ] to [漢] meaning kanji conversion. |
|
654 |
- |
|
655 |
- |
|
656 |
-```nohighlight |
|
657 |
-| 京都大学 | |
|
658 |
-``` |
|
659 |
- |
|
660 |
- |
|
661 |
-And then press the Space key once more, the next candidate is displayed. To determine the conversion, press the Enter key or `C-l` . You can also change the length of a segment by pressing `C-i` or `C-o` . When you execute kanji conversion for one of the segments, move the cursor to the target segment and press the Space key. To cancel a kanji conversion, press `C-c` . |
|
662 |
- |
|
663 |
-**<ins>Moving Cursor</ins>** |
|
664 |
- |
|
665 |
- How to move a cursor is as below. |
|
666 |
- |
|
667 |
- |
|
668 |
-col 1 | col 2 |
|
669 |
-`C-p` | move up |
|
670 |
-`C-n` | move down |
|
671 |
-`C-f` | move right |
|
672 |
-`C-b` | move left |
|
673 |
-`C-a` | move to the beginning of the line |
|
674 |
-`C-e` | move to the end of the line |
|
675 |
- |
|
676 |
-Each of the commands mean: p of `C-p` is previous, n of `C-n` is next, f of `C-f` is forward, b of `C-b` is backward, a of `C-a` is ahead, and e of `C-e` is end of line. |
|
677 |
- |
|
678 |
-col 1 | col 2 |
|
679 |
-`C-v` | scroll the screen to the next view |
|
680 |
-`M-v` (press ESC, release it, and then press v) | scroll the screen to the previous view |
|
681 |
-`M-<` | move to the top of the buffer |
|
682 |
-`M->` | move to the bottom of the buffer |
|
683 |
- |
|
684 |
-![](348_907.jpeg) |
|
685 |
- |
|
686 |
-**<ins>Deletion and Copying</ins>** |
|
687 |
- |
|
688 |
-There are several ways to delete a character. |
|
689 |
- |
|
690 |
- |
|
691 |
-col 1 | col 2 |
|
692 |
- Delete key | Deletes one character to the left. |
|
693 |
-`C-d` | Deletes one character to the right of the cursor. |
|
694 |
-`C-k` | Deletes characters from the right of the cursor to the end of the line. |
|
695 |
- |
|
696 |
- |
|
697 |
- |
|
698 |
-You can also delete a specified section of text. First, mark the cursor position as the base of the section by pressing `C-`@ . The message “Mark set” on the echo line indicates that the current cursor position has been marked. |
|
699 |
-Next, move the cursor to indicate the section that you want to delete and press `C-w` . This deletes the section that spans from the marked position to the current cursor position. |
|
700 |
- |
|
701 |
-Texts deleted by `C-k` and `C-w` are saved in the copy buffer, you can paste the deleted texts by pressing `C-y` . The copy buffer is overwritten every time `C-k` or `C-w` is pressed. Note that texts deleted by `C-d` and the Delete key are not saved in the copy buffer. |
|
702 |
- |
|
703 |
-**<ins>Canceling and Undoing Operations</ins>** |
|
704 |
- |
|
705 |
-To cancel the operation, press `C-g` . When this cancel command is accepted, the echo line shows the Quit message. |
|
706 |
-To cancel the last action you performed, press `C-x u` . The echo line shows the message “Undo!” |
|
707 |
- |
|
708 |
-**<ins>Saving File ( <code>C-x</code> <code>C-s</code> )</ins>** |
|
709 |
- |
|
710 |
- To save a buffer you are editing, press `C-x` `C-s` . If you have been editing a **scratch** buffer, pressing `C-x` `C-s` shows “File to save in: ~/” on the echo line. You specify a save destination filename. |
|
711 |
- |
|
712 |
- |
|
713 |
- |
|
714 |
-**<ins>Erasing Editing Buffer</ins>** |
|
715 |
- |
|
716 |
- To erase an editing buffer, press `C-x k` . The echo line shows “Kill buffer: (default test.txt)”. Then you press the Enter key. If the editing buffer has not been edited, it is erased without any message. If the editing buffer has been edited, the echo line shows “Buffer test.txt modified; kill anyway– (yes or no).” To erase the buffer with the edited content canceled, enter “yes” and press the Enter key. To cancel the erasion of the editing buffer, enter “no” and then press the Enter key. |
|
717 |
- |
|
718 |
- |
|
719 |
- |
|
720 |
- |
|
721 |
-### Finishing Emacs {#emacs_end} |
|
722 |
- |
|
723 |
-To finish **Emacs**, press `C-x` `C-c` . If there is an unsaved editing buffer, the echo line shows a message of the format as shown below. ( The following filename part is an example. ) |
|
724 |
- |
|
725 |
- |
|
726 |
-```nohighlight |
|
727 |
-Save file /home/a/b59999/test.txt– (y, n, !, ., q, C-r or C-h) |
|
728 |
-``` |
|
729 |
- |
|
730 |
- |
|
731 |
-To save the file before finishing **Emacs**, enter “y” and then press the Enter key. If you do not save the file, enter “n” and press the Enter key. A message shows again on the echo line as below. If you really want to finish without saving the file, enter “yes” and then press the Enter key. If you enter “no” and then press the Enter key, the quitting process is canceled. |
|
732 |
- |
|
733 |
- |
|
734 |
-```nohighlight |
|
735 |
-Modified buffers exist; exit anyway– (yes or no) |
|
736 |
-``` |
|
737 |
- |
|
738 |
- |
|
739 |
- |
|
740 |
-### To Master Emacs{#emacs_master} |
|
741 |
- |
|
742 |
-**Emacs** provides a tutorial. Please try it if you want to master **Emacs** quickly. In the tutorial, you will learn a lot of other functions that are not introduced here. The tutorial starts by pressing `M-–` `t` . The tutorial uses a buffer. Erase it by `C-x` `k` when you finish the tutorial. |
|
1 |
+--- |
|
2 |
+title: 'Unix/Linux Basics' |
|
3 |
+taxonomy: |
|
4 |
+ category: |
|
5 |
+ - docs |
|
6 |
+--- |
|
7 |
+ |
|
8 |
+[toc] |
|
9 |
+ |
|
10 |
+## File System{#system} |
|
11 |
+ |
|
12 |
+ |
|
13 |
+### File and Directory{#file} |
|
14 |
+ |
|
15 |
+Various types of data that users create are recorded as **files** , and be stored in containers that called **directories** . You can create a directory in a directory and manage files hierarchically. |
|
16 |
+ |
|
17 |
+![](348_901.jpg) |
|
18 |
+ |
|
19 |
+This file structure is called the tree structure because it looks like a tree with branches. In UNIX, the root of the tree is called the **root directory** and denoted by “/ (slash).” The directory that a user is working is called the **current directory**. |
|
20 |
+ |
|
21 |
+### Absolute Path and Relative Path{#path} |
|
22 |
+ |
|
23 |
+The concept the **path** is needed to specify a file on the tree structure. You can specify a file in two methods: **absolute path** and **relative path**. |
|
24 |
+ |
|
25 |
+* **Absolute path method** |
|
26 |
+ |
|
27 |
+This method is to specify files based on the root directory. |
|
28 |
+ |
|
29 |
+(Example)the case of specifying the “report1.txt” in Figure 1. |
|
30 |
+ |
|
31 |
+ |
|
32 |
+```nohighlight |
|
33 |
+/home/a/b59999/report/report1.txt |
|
34 |
+``` |
|
35 |
+ |
|
36 |
+ |
|
37 |
+* **Relative path method** |
|
38 |
+ |
|
39 |
+This method is to specify files based on the current directory. |
|
40 |
+ |
|
41 |
+ (Example)the case of specifying the “report1.txt” in Figure 1 based on the current directory “/home/a/b59999.” |
|
42 |
+ |
|
43 |
+ |
|
44 |
+ |
|
45 |
+ |
|
46 |
+```nohighlight |
|
47 |
+report/report1.txt |
|
48 |
+``` |
|
49 |
+ |
|
50 |
+ |
|
51 |
+ |
|
52 |
+## Basic Commands{#command} |
|
53 |
+ |
|
54 |
+ |
|
55 |
+This section describes basic commands commonly used in UNIX. |
|
56 |
+ |
|
57 |
+ |
|
58 |
+### `pwd` -Command for Displaying Current Directory{#pwd} |
|
59 |
+ |
|
60 |
+ |
|
61 |
+```nohighlight |
|
62 |
+pwd |
|
63 |
+``` |
|
64 |
+ |
|
65 |
+ |
|
66 |
+**Example** |
|
67 |
+ |
|
68 |
+ |
|
69 |
+```nohighlight |
|
70 |
+[b59999@hx001 ~]$ pwd |
|
71 |
+``` |
|
72 |
+ |
|
73 |
+```nohighlight |
|
74 |
+/home/a/b59999 # The current directory is displayed |
|
75 |
+``` |
|
76 |
+ |
|
77 |
+ |
|
78 |
+ |
|
79 |
+### `ls` -Command for Displaying File List{#ls} |
|
80 |
+ |
|
81 |
+ |
|
82 |
+```nohighlight |
|
83 |
+ls [option] [filename directory name] |
|
84 |
+``` |
|
85 |
+ |
|
86 |
+ |
|
87 |
+**Main Option** |
|
88 |
+ |
|
89 |
+Option | Effect |
|
90 |
+------ | -------------------------------------------------------------- |
|
91 |
+ -l | Displays details of files |
|
92 |
+ -F | Display attributes clearly marked with "/ (slash)" for directories, "* (asterisk)" for executable files. |
|
93 |
+ -a | Display files beginning with a " . (dot)" used in the system, etc. |
|
94 |
+ |
|
95 |
+ |
|
96 |
+ |
|
97 |
+**Example** |
|
98 |
+ |
|
99 |
+ |
|
100 |
+```nohighlight |
|
101 |
+[b59999@hx001 ~]$ ls |
|
102 |
+``` |
|
103 |
+ |
|
104 |
+```nohighlight |
|
105 |
+file1.txt file2.bmp dir1 # A file is displayed. |
|
106 |
+[b59999@hx001 ~]$ ls -a |
|
107 |
+``` |
|
108 |
+ |
|
109 |
+```nohighlight |
|
110 |
+. .cshrc .tcshrc file1.txt dir1 #A file starting with “.” are also displayed. |
|
111 |
+.. .login .bashrc file2.bmp |
|
112 |
+.. .login .bashrc file2.bmp |
|
113 |
+[b59999@hx001 ~]$ ls -F |
|
114 |
+``` |
|
115 |
+ |
|
116 |
+```nohighlight |
|
117 |
+file1.txt file2.bmp dir1/ # "/" is appended to a directory. |
|
118 |
+[b59999@hx001 ~]$ |
|
119 |
+``` |
|
120 |
+ |
|
121 |
+ |
|
122 |
+ |
|
123 |
+### `cd` -Command for Moving Current Directory{#cd} |
|
124 |
+ |
|
125 |
+ |
|
126 |
+```nohighlight |
|
127 |
+cd [directory_name] |
|
128 |
+``` |
|
129 |
+ |
|
130 |
+ |
|
131 |
+**Example** |
|
132 |
+ |
|
133 |
+ |
|
134 |
+```nohighlight |
|
135 |
+[b59999@hx001 ~]$ pwd |
|
136 |
+``` |
|
137 |
+ |
|
138 |
+```nohighlight |
|
139 |
+/home/a/b59999 # The current directory is /home/a/b59999. |
|
140 |
+``` |
|
141 |
+ |
|
142 |
+```nohighlight |
|
143 |
+[b59999@hx001 ~]$ cd dir1 # Move the current directory to dir1. |
|
144 |
+[b59999@hx001 ~]$ pwd |
|
145 |
+``` |
|
146 |
+ |
|
147 |
+```nohighlight |
|
148 |
+/home/a/b59999/dir1 # The current directory has been moved to dir1. |
|
149 |
+``` |
|
150 |
+ |
|
151 |
+ |
|
152 |
+ |
|
153 |
+### `cp` -Command for Copying Files and Directories{#cp} |
|
154 |
+ |
|
155 |
+ |
|
156 |
+```nohighlight |
|
157 |
+cp [options] [copy_source] [copy_destination] |
|
158 |
+``` |
|
159 |
+ |
|
160 |
+ |
|
161 |
+**Main Option** |
|
162 |
+ |
|
163 |
+Option | Effect |
|
164 |
+------ | -------------------------------------------- |
|
165 |
+ -R | If the copy source is a directory, the tree structure under the directory is copied, including its tree structure. |
|
166 |
+ |
|
167 |
+ |
|
168 |
+ |
|
169 |
+**Example** |
|
170 |
+ |
|
171 |
+ |
|
172 |
+```nohighlight |
|
173 |
+[b59999@hx001 ~]$ ls -F |
|
174 |
+file1.txt dir1/ |
|
175 |
+``` |
|
176 |
+ |
|
177 |
+```nohighlight |
|
178 |
+[b59999@hx001 ~]$ cp file1.txt file2.txt #Copy file1.txt as file2.txt. |
|
179 |
+[b59999@hx001 ~]$ ls -F |
|
180 |
+``` |
|
181 |
+ |
|
182 |
+```nohighlight |
|
183 |
+file1.txt file2.bmp dir1/ # file2.txt has been created. |
|
184 |
+``` |
|
185 |
+ |
|
186 |
+```nohighlight |
|
187 |
+[b59999@hx001 ~]$ cp file2.txt dir1 # Copy file2.txt to dir1. |
|
188 |
+[b59999@hx001 ~]$ ls dir1 |
|
189 |
+``` |
|
190 |
+ |
|
191 |
+```nohighlight |
|
192 |
+file2.txt # file2.txt has been copied to dir1. |
|
193 |
+``` |
|
194 |
+ |
|
195 |
+```nohighlight |
|
196 |
+[b59999@hx001 ~]$ cp -R dir1 dir2 # Copy dir1 to dir2. |
|
197 |
+[b59999@hx001 ~]$ ls -F |
|
198 |
+``` |
|
199 |
+ |
|
200 |
+```nohighlight |
|
201 |
+file1.txt file2.txt dir1/ dir2/ # dir2 has been created. |
|
202 |
+[b59999@hx001 ~]$ ls dir2 |
|
203 |
+``` |
|
204 |
+ |
|
205 |
+```nohighlight |
|
206 |
+file2.txt # dir1 is copied to dir2 including the tree structure. |
|
207 |
+[b59999@hx001 ~]$ |
|
208 |
+``` |
|
209 |
+ |
|
210 |
+ |
|
211 |
+ |
|
212 |
+### `mkdir` -Command for Making New Directories{#mkdir} |
|
213 |
+ |
|
214 |
+ |
|
215 |
+```nohighlight |
|
216 |
+mkdir directory name] |
|
217 |
+``` |
|
218 |
+ |
|
219 |
+ |
|
220 |
+**Example** |
|
221 |
+ |
|
222 |
+ |
|
223 |
+```nohighlight |
|
224 |
+[b59999@hx001 ~]$ ls |
|
225 |
+file1.txt file2.bmp |
|
226 |
+[b59999@hx001 ~]$ mkdir dir1 |
|
227 |
+[b59999@hx001 ~]$ ls -F |
|
228 |
+``` |
|
229 |
+ |
|
230 |
+```nohighlight |
|
231 |
+file1.txt file2.bmp dir1/ # dir1 has been created. |
|
232 |
+[b59999@hx001 ~]$ |
|
233 |
+``` |
|
234 |
+ |
|
235 |
+ |
|
236 |
+ |
|
237 |
+### `rm` -Command for Deleting Files and Directories{#rm} |
|
238 |
+ |
|
239 |
+ |
|
240 |
+```nohighlight |
|
241 |
+rm [option] [filename directory name] |
|
242 |
+``` |
|
243 |
+ |
|
244 |
+ |
|
245 |
+**Main Option** |
|
246 |
+ |
|
247 |
+Option | Effect |
|
248 |
+------- | ---------------------------------------- |
|
249 |
+ -R | If the target is a directory, delete it including the tree structure under the directory. |
|
250 |
+ |
|
251 |
+ |
|
252 |
+ |
|
253 |
+**Example** |
|
254 |
+ |
|
255 |
+ |
|
256 |
+```nohighlight |
|
257 |
+[b59999@hx001 ~]$ ls -F |
|
258 |
+file1.txt file2.bmp dir1/ |
|
259 |
+``` |
|
260 |
+ |
|
261 |
+```nohighlight |
|
262 |
+[b59999@hx001 ~]$ rm file1.txt # Delete file1.txt. |
|
263 |
+[b59999@hx001 ~]$ ls -F |
|
264 |
+``` |
|
265 |
+ |
|
266 |
+```nohighlight |
|
267 |
+file2.bmp dir1/ # file1.txt has been deleted. |
|
268 |
+[b59999@hx001 ~]$ ls -F dir1 |
|
269 |
+``` |
|
270 |
+ |
|
271 |
+```nohighlight |
|
272 |
+dir2/ # dir2 is under dir1. |
|
273 |
+``` |
|
274 |
+ |
|
275 |
+```nohighlight |
|
276 |
+[b59999@hx001 ~]$ rm -R dir1 # Delete dir1. |
|
277 |
+[b59999@hx001 ~]$ ls -F |
|
278 |
+``` |
|
279 |
+ |
|
280 |
+```nohighlight |
|
281 |
+file2.bmp # dir1 and its tree structure are deleted. |
|
282 |
+``` |
|
283 |
+ |
|
284 |
+ |
|
285 |
+ |
|
286 |
+### `mv` -Command for Moving Files (for Changing Filenames){#mv} |
|
287 |
+ |
|
288 |
+The mv command is used to move files and directories. This command can also be used to change the filename, by moving a file to the same directory. |
|
289 |
+ |
|
290 |
+ |
|
291 |
+```nohighlight |
|
292 |
+mv [source_filename] [new_filename] |
|
293 |
+``` |
|
294 |
+ |
|
295 |
+ |
|
296 |
+**Example** |
|
297 |
+ |
|
298 |
+ |
|
299 |
+```nohighlight |
|
300 |
+[b59999@hx001 ~]$ ls -F |
|
301 |
+file1.txt file2.bmp dir1/ |
|
302 |
+``` |
|
303 |
+ |
|
304 |
+```nohighlight |
|
305 |
+[b59999@hx001 ~]$ mv file1.txt dir1 # Move file1.txt to dir1. |
|
306 |
+[b59999@hx001 ~]$ ls -F |
|
307 |
+``` |
|
308 |
+ |
|
309 |
+```nohighlight |
|
310 |
+file2.bmp dir1/ # file1.txt no longer exists. |
|
311 |
+[b59999@hx001 ~]$ ls dir1 |
|
312 |
+``` |
|
313 |
+ |
|
314 |
+```nohighlight |
|
315 |
+file1.txt # Moved to dir1. |
|
316 |
+``` |
|
317 |
+ |
|
318 |
+```nohighlight |
|
319 |
+[b59999@hx001 ~]$ mv file2.bmp file3.bmp # Move file2.bmp to file3.bmp. |
|
320 |
+[b59999@hx001 ~]$ ls -F |
|
321 |
+``` |
|
322 |
+ |
|
323 |
+```nohighlight |
|
324 |
+file3.bmp dir1/ # The filename has been changed to file3.bmp. |
|
325 |
+``` |
|
326 |
+ |
|
327 |
+### `cat` -Command for Displaying File Contents on Screen{#cat} |
|
328 |
+ |
|
329 |
+ |
|
330 |
+```nohighlight |
|
331 |
+cat [filename] |
|
332 |
+``` |
|
333 |
+ |
|
334 |
+ |
|
335 |
+**Example** |
|
336 |
+ |
|
337 |
+ |
|
338 |
+```nohighlight |
|
339 |
+[b59999@hx001 ~]$ ls -F |
|
340 |
+file1.txt file2.bmp dir1/ |
|
341 |
+[b59999@hx001 ~]$ cat file1.txt |
|
342 |
+``` |
|
343 |
+ |
|
344 |
+```nohighlight |
|
345 |
+abcdefghijklmnopqrstuvwxyz # The content of file1.txt is displayed. |
|
346 |
+[b59999@hx001 ~]$ |
|
347 |
+``` |
|
348 |
+ |
|
349 |
+ |
|
350 |
+### `more` and `less` -Commands for Displaying File Contents{#less} |
|
351 |
+ |
|
352 |
+ |
|
353 |
+If you use the `more` or `less` command instead of the `cat` command, it stops displaying each page and waits for a command in the case the file is long. |
|
354 |
+ |
|
355 |
+ |
|
356 |
+ |
|
357 |
+```nohighlight |
|
358 |
+more(or less ) [filename] |
|
359 |
+``` |
|
360 |
+ |
|
361 |
+ |
|
362 |
+**Example** |
|
363 |
+ |
|
364 |
+ |
|
365 |
+```nohighlight |
|
366 |
+[b59999@hx001 ~]$ more file3.c |
|
367 |
+#include <stdio.h> /* The content of file3.c is displayed. */ |
|
368 |
+#include <math.h> |
|
369 |
+#include <stdlib.h> |
|
370 |
+(・・omission・・) |
|
371 |
+ for(i=0; i<10; i++){ |
|
372 |
+ a[i] = b[i]*c[i]; |
|
373 |
+--More--(10%) |
|
374 |
+ |
|
375 |
+ Press space key to advance to the next page. |
|
376 |
+ |
|
377 |
+``` |
|
378 |
+ |
|
379 |
+### `logout` -Command for Logout{#logout} |
|
380 |
+ |
|
381 |
+ |
|
382 |
+```nohighlight |
|
383 |
+logout |
|
384 |
+``` |
|
385 |
+ |
|
386 |
+ |
|
387 |
+**Example** |
|
388 |
+ |
|
389 |
+ |
|
390 |
+ |
|
391 |
+```nohighlight |
|
392 |
+[b59999@hx001 ~]$ logout # Log out |
|
393 |
+``` |
|
394 |
+ |
|
395 |
+ |
|
396 |
+ |
|
397 |
+### `man` -Command for Viewing Manual(View a description of each command.){#man} |
|
398 |
+ |
|
399 |
+**Display the description of the ls command** |
|
400 |
+ |
|
401 |
+ |
|
402 |
+```nohighlight |
|
403 |
+[b59999@hx001 ~]$ man ls |
|
404 |
+``` |
|
405 |
+ |
|
406 |
+To display `man` command messages in Japanese, set the ssh client character encoding to UTF-8 and set the environment variable LANG to ja_JP.UTF-8. |
|
407 |
+ |
|
408 |
+**If you are using tcsh** |
|
409 |
+ |
|
410 |
+ |
|
411 |
+```nohighlight |
|
412 |
+[b59999@hx001 ~]$ setenv LANG ja_JP.UTF-8 |
|
413 |
+``` |
|
414 |
+ |
|
415 |
+ |
|
416 |
+**If you are using bash** |
|
417 |
+ |
|
418 |
+ |
|
419 |
+```nohighlight |
|
420 |
+[b59999@hx001 ~]$ export LANG=ja_JP.UTF-8 |
|
421 |
+``` |
|
422 |
+ |
|
423 |
+ |
|
424 |
+ |
|
425 |
+ |
|
426 |
+## How to Use vi Editor{#vi} |
|
427 |
+ |
|
428 |
+The vi editor is a text editor that comes standard with UNIX-like operating systems. Its operating system is very specific and we describe in detail below. |
|
429 |
+ |
|
430 |
+**How to Start vi Editor** |
|
431 |
+ |
|
432 |
+ |
|
433 |
+```nohighlight |
|
434 |
+vi [filename] |
|
435 |
+``` |
|
436 |
+ |
|
437 |
+ |
|
438 |
+**Two Modes of vi Editor** |
|
439 |
+ |
|
440 |
+The vi editor has two modes of **command mode** and **edit mode**. |
|
441 |
+ |
|
442 |
+* **Command mode** |
|
443 |
+ |
|
444 |
+Performs tasks other than text entry, such as searching, replacing, saving files, and deleting characters and lines. |
|
445 |
+ |
|
446 |
+* **Edit mode** |
|
447 |
+ |
|
448 |
+Enter the actual text. |
|
449 |
+ |
|
450 |
+When you start the editor, the command mode comes up first. You can enter the edit mode with insert commands such as `i`, `I`, `a`, `A`, `o`, or `O`. To return to command mode, press the ESC key. |
|
451 |
+ |
|
452 |
+### vi Command Reference{#vi} |
|
453 |
+ |
|
454 |
+**Moving Cursor** |
|
455 |
+ |
|
456 |
+Character Oriented Jump | |
|
457 |
+--------------- | -------------------------- |
|
458 |
+ h , j , k , l | left, down, up, right ( ← , ↓ , ↑ , → ) |
|
459 |
+ |
|
460 |
+Text Oriented Jump | |
|
461 |
+--------------- | -------------- |
|
462 |
+ w , W , b , B | Previous/next word |
|
463 |
+ e , E | End of the word |
|
464 |
+ ) , ( | Beginning of next/previous sentence |
|
465 |
+ } , { | Beginning of next/previous paragraph |
|
466 |
+ ]] , [[ | Beginning of next/previous section |
|
467 |
+ |
|
468 |
+Line Oriented Jump | |
|
469 |
+----------- | ------------------- |
|
470 |
+ 0(zero) , $ | Beginning/end of the current line |
|
471 |
+ ^ | First character (other than space) of the current line |
|
472 |
+ + , ? | First character of the next/previous line |
|
473 |
+_n_l | _n_’th character of the current line |
|
474 |
+ H | First line on the screen |
|
475 |
+ M | Center line on the screen |
|
476 |
+ L | Bottom line on the screen |
|
477 |
+_n_H | _n_’th line from the top |
|
478 |
+_n_L | _n_’th line from the bottom |
|
479 |
+ |
|
480 |
+Screen Oriented Jump | |
|
481 |
+------------------------------------------------------------------------ | -------------------- |
|
482 |
+CTRL + f , CTRL + b | Scroll to the next/previous screen |
|
483 |
+CTRL + d , CTRL + u | Scroll up/down the half screen |
|
484 |
+CTRL + e , CTRL + y | Display another line at the bottom/top of the window |
|
485 |
+ z RETURN | Display the line with the cursor at the top of the screen |
|
486 |
+ z. (zed dot) | Display the line with the cursor in the center of the screen |
|
487 |
+ z- (zed hyphen) | Display the line with the cursor at the bottom of the screen |
|
488 |
+CTRL + l , CTRL + r | Rewrite Screen (without scrolling) |
|
489 |
+ |
|
490 |
+Search | |
|
491 |
+------------ | -------------------------------------- |
|
492 |
+ / _pattern_ | Search for patterns in the forward direction |
|
493 |
+ ? _pattern_ | Search for patterns in the backward direction |
|
494 |
+ n , N | Repeat the last search in the same/opposite direction |
|
495 |
+ / , ? | Repeat the previous search in the forward/backward direction |
|
496 |
+ f_x_ | Jump to _x_ after the cursor position in the current line |
|
497 |
+ F_x_ | Jump to _x_ before the cursor position in the current line |
|
498 |
+ t_x_ | Jump to the character immediately before the _x_ after the cursor position in the current line |
|
499 |
+ T_x_ | Jump to the character immediately after the _x_ before the cursor position in the current line |
|
500 |
+ ; | Repeat last search in the current line |
|
501 |
+ , | Repeat last search in the current line in the opposite direction |
|
502 |
+ |
|
503 |
+Jump by Line Number | |
|
504 |
+----------------------------------- | --------------- |
|
505 |
+CTRL + g | Display current line number |
|
506 |
+_n_G | Jump to line number _n_ |
|
507 |
+ G | Jump to last line of file |
|
508 |
+ :_n_ | Jump to line number _n_ |
|
509 |
+ |
|
510 |
+ |
|
511 |
+Mark of Position| |
|
512 |
+------- | ----------------------- |
|
513 |
+ m_x_ | Mark current position as _x_ |
|
514 |
+ ‘_x_ | Jump to _x |
|
515 |
+ “ | Return to the previous mark or context |
|
516 |
+ `_x_ | Mark to jumps to the beginning of the line containing _x_. |
|
517 |
+ `` | Return to the beginning of the line containing the previous mark |
|
518 |
+ |
|
519 |
+**Exit Command** |
|
520 |
+ |
|
521 |
+Exit Command | |
|
522 |
+------- | --------------------------------- |
|
523 |
+ ZZ | Write (save) a file and exit |
|
524 |
+ :x | Write (save) a file and exit |
|
525 |
+ :wq | Write (save) a file and exit |
|
526 |
+ :w | Writing (saving) a file |
|
527 |
+ :w! | (Forced) file writing (saving) |
|
528 |
+ :q | Finish editing the file |
|
529 |
+ :q! | Finish editing the file (cancel all changes) |
|
530 |
+ :e! | Return to the current file to the contents at the time it was last written (saved) |
|
531 |
+ |
|
532 |
+**Edit command** |
|
533 |
+ |
|
534 |
+Inserting | |
|
535 |
+------------------- | ---------------------------- |
|
536 |
+`i` , `a` | Insert text before/after the cursor |
|
537 |
+`I` , `A` | Insert text at the beginning/end of the line |
|
538 |
+`o` , `O` (Capitalized O) | Open new line for entering text below/above the cursor |
|
539 |
+ |
|
540 |
+ Change | |
|
541 |
+---- | ------------------ |
|
542 |
+`r` | Change characters |
|
543 |
+`cw` | Change words |
|
544 |
+`cc` | Change current line |
|
545 |
+`C` | Change to the end of line |
|
546 |
+`R` | Overwrite text strings |
|
547 |
+`s` | Replace characters with text |
|
548 |
+`S` | Replace current line with text |
|
549 |
+ |
|
550 |
+Moving and Deleting | |
|
551 |
+--------- | -------------------------------------------------- |
|
552 |
+`x` | Delete characters |
|
553 |
+`X` | Delete character before the cursor |
|
554 |
+`dw` | Delete words |
|
555 |
+`dd` | Delete current line |
|
556 |
+`D` | Delete to the end of the line |
|
557 |
+`p` , `P` | Insert deleted text after/before the cursor |
|
558 |
+ “_n_p | Insert text with delete buffer number _n_ after the cursor (valid for the last 9 deletions) |
|
559 |
+ |
|
560 |
+Yank | |
|
561 |
+--------- | ----------------------------- |
|
562 |
+`yw` | Yank (copy) word |
|
563 |
+`yy` | Yank current line |
|
564 |
+ “_a_yy | Yank current line to the buffer named _a_ |
|
565 |
+`p` , `P` | Paste yanked text after/before the cursor |
|
566 |
+ “_a_p | Insert text of buffer _a_ before the cursor |
|
567 |
+ |
|
568 |
+Other Commands | |
|
569 |
+--------- | ----------------------------- |
|
570 |
+ . (dot) | Repeat the last editing command |
|
571 |
+`u` , `U` | Undo the last edition/recover current line |
|
572 |
+`j` | Concatenate two lines |
|
573 |
+ |
|
574 |
+Using ex Command | |
|
575 |
+---------------- | --------------------- |
|
576 |
+ :d | Delete a line |
|
577 |
+ :m | Move a line |
|
578 |
+ :co , :t | Copy a line |
|
579 |
+ / , ? | Repeat previous search forward/backward |
|
580 |
+ :.,$d | Delete from the current line to the last line of the file |
|
581 |
+ |
|
582 |
+ |
|
583 |
+## How to Use Emacs{#emacs} |
|
584 |
+ |
|
585 |
+ |
|
586 |
+ |
|
587 |
+### What is Emacs–{#emacs_top} |
|
588 |
+ |
|
589 |
+**Emacs** is a sophisticated highly customizable text editor often used on UNIX family OS. |
|
590 |
+When editing using **Emacs**, you read a file into a buffer, work on it, and then write the edited buffer to the file. |
|
591 |
+In **Emacs** editing work, you can switch between multiple editing files, and each buffer is assigned with a name. Usually, the name of the file to be edited is the name of the buffer. |
|
592 |
+ |
|
593 |
+ |
|
594 |
+ |
|
595 |
+ |
|
596 |
+### Starting Emacs{#emacs_boot} |
|
597 |
+ |
|
598 |
+ |
|
599 |
+```nohighlight |
|
600 |
+emacs [filename] |
|
601 |
+``` |
|
602 |
+ If a filename is specified when starting, an edit buffer is created with the same name and the file content is loaded. |
|
603 |
+(If there is no file to read, the editing buffer becomes empty.) If a filename is not specified, an editing buffer named **scratch** is created. |
|
604 |
+ |
|
605 |
+### Emacs Screen{#emacs_display} |
|
606 |
+ |
|
607 |
+When you launch in an environment where X (window system) is available, a new window will be launched as an X client. |
|
608 |
+ |
|
609 |
+![](348_902.jpg) |
|
610 |
+ |
|
611 |
+If the window system is not available in your environment, the following screen will appear. |
|
612 |
+ |
|
613 |
+![](348_903.jpg) |
|
614 |
+ |
|
615 |
+The **Emacs** screen consists of three sections. |
|
616 |
+ |
|
617 |
+* **Text window** |
|
618 |
+ |
|
619 |
+Largest section. The text you have entered will be displayed. |
|
620 |
+ |
|
621 |
+* **Mode line** |
|
622 |
+ |
|
623 |
+It is the black and white reversal line at the bottom of the text window. it shows status of the text window. |
|
624 |
+ |
|
625 |
+An inverted line at the bottom of the text window. It displays the status of the text window. |
|
626 |
+The approximate meaning of the mode line is as follows. |
|
627 |
+ |
|
628 |
+ |
|
629 |
+![](348_904.jpg) |
|
630 |
+ |
|
631 |
+* **Echo line** |
|
632 |
+ |
|
633 |
+The line below the mode line. Messages from **Emacs** will be displayed. It is also used to input. |
|
634 |
+ |
|
635 |
+### Basic Operations of Emacs{#emacs_use} |
|
636 |
+ |
|
637 |
+Operations such as moving the cursor use special key input. There are two ways of special key input as below. |
|
638 |
+ |
|
639 |
+* Enter a character key with the **CTRL key** pressed down (**C-[character_key]** ). |
|
640 |
+ |
|
641 |
+* Enter a character key after pressing the ESC key ( **M-[character_key]** ). |
|
642 |
+ |
|
643 |
+**<ins>Open a file( <code>C-x</code> <code>C-f</code> )</ins>** |
|
644 |
+ |
|
645 |
+After starting up **Emacs**, enter `C-x` `C-f` (enter x with CTRL pressed then enter f with CTRL pressed) to load a new file. The following message will appear on the echo line. |
|
646 |
+ |
|
647 |
+ ```nohighlight |
|
648 |
+ Find file: ~/ |
|
649 |
+ ``` |
|
650 |
+ |
|
651 |
+If **Emacs** is started from a directory other than the home directory, the path of the current directory will be displayed instead of /~. |
|
652 |
+Enter the name of the file you want to open (e.g. test.txt) followed by the message and press Enter. |
|
653 |
+ |
|
654 |
+ |
|
655 |
+```nohighlight |
|
656 |
+Find file: ~/test.txt |
|
657 |
+``` |
|
658 |
+ |
|
659 |
+A buffer named test.txt is created, and the content of the file is read to the buffer. If the file does not exist, a message (New file) is shown on the echo line. |
|
660 |
+ |
|
661 |
+ |
|
662 |
+![](348_905.jpg) |
|
663 |
+ |
|
664 |
+**<ins>Enter the Text</ins>** |
|
665 |
+ |
|
666 |
+Characters are entered at the cursor position on the text window. To delete a character, use the Delete key. (The Backspace key is not used to delete characters.) |
|
667 |
+ |
|
668 |
+**<ins>Japanese Input System</ins>** |
|
669 |
+ |
|
670 |
+To enter Japanese, you need start the Japanese input system by pressing `C-¥` (press ¥ [backslash] with CTRL pressed). When the system starts, the display in the left corner of the mode line will switch from [ ? - ] to [ A ], which enables romaji kana conversion. To switch off the input system, press `C-¥` again. |
|
671 |
+ |
|
672 |
+If you type "k y o u t o d a i g a k u" in a Japanese input system, you will see the following. |
|
673 |
+ |
|
674 |
+ |
|
675 |
+```nohighlight |
|
676 |
+| きょうとだいがく | |
|
677 |
+``` |
|
678 |
+ |
|
679 |
+The vertical bars “|” on the both sides indicate that characters in between can be converted to kanji characters. Press the Space key to convert into kanji. The mark at the left corner is changed from [あ] to [漢] meaning kanji conversion. |
|
680 |
+ |
|
681 |
+```nohighlight |
|
682 |
+| 京都大学 | |
|
683 |
+``` |
|
684 |
+ |
|
685 |
+And then press the Space key once more, the next candidate is displayed. To determine the conversion, press the Enter key or `C-l` . You can also change the length of a segment by pressing `C-i` or `C-o` . When you execute kanji conversion for one of the segments, move the cursor to the target segment and press the Space key. To cancel a kanji conversion, press `C-c` . |
|
686 |
+ |
|
687 |
+**<ins>Moving Cursor</ins>** |
|
688 |
+ |
|
689 |
+ How to move a cursor is as below. |
|
690 |
+ |
|
691 |
+col 1 | col 2 |
|
692 |
+----- | --------- |
|
693 |
+`C-p` | move up |
|
694 |
+`C-n` | move down |
|
695 |
+`C-f` | move right |
|
696 |
+`C-b` | move left |
|
697 |
+`C-a` | move to the beginning of the line |
|
698 |
+`C-e` | move to the end of the line |
|
699 |
+ |
|
700 |
+Each of the commands mean: p of `C-p` is previous, n of `C-n` is next, f of `C-f` is forward, b of `C-b` is backward, a of `C-a` is ahead, and e of `C-e` is end of line. |
|
701 |
+ |
|
702 |
+ |
|
703 |
+col 1 | col 2 |
|
704 |
+--------------------------------------------------- | ------------ |
|
705 |
+`C-v` | Scroll to the next screen |
|
706 |
+`M-v` ( press ESC, release it, and then press v) | Scroll to the previous screen |
|
707 |
+`M-<` | move to the top of the buffer |
|
708 |
+`M->` | move to the bottom of the buffer |
|
709 |
+ |
|
710 |
+![](348_907.jpg) |
|
711 |
+ |
|
712 |
+**<ins>Delete and Copy</ins>** |
|
713 |
+ |
|
714 |
+There are several ways to delete a character. |
|
715 |
+ |
|
716 |
+ |
|
717 |
+col 1 | col 2 |
|
718 |
+----------- | --------------------- |
|
719 |
+ Delete key | Deletes one character to the left. |
|
720 |
+`C-d` | Deletes one character to the right of the cursor. |
|
721 |
+`C-k` | Deletes characters from the right of the cursor to the end of the line. |
|
722 |
+ |
|
723 |
+You can also delete a specified section of text. First, move the cursor to the beginning of the range you want to specify and mark it with `C-`@. "Mark set" will appear on the echo line. Next, move the cursor to the end of the range and press `C-w`. And you can delete the entire marked range from the current cursor position. |
|
724 |
+ |
|
725 |
+Texts deleted by `C-k` and `C-w` are saved in the copy buffer and you can paste the deleted texts by pressing `C-y` . The copy buffer is overwritten every time `C-k` or `C-w` is pressed. Note that texts deleted by `C-d` and the Delete key are not saved in the copy buffer. |
|
726 |
+ |
|
727 |
+**<ins>Undo Operations</ins>** |
|
728 |
+ |
|
729 |
+To undo the operation, press `C-g` . "Quit" is displayed on the echo line.To undo the last editing operation, press `C-x` `u`. "Undo!" is displayed on the echo line. |
|
730 |
+ |
|
731 |
+**<ins>Save the File( <code>C-x</code> <code>C-s</code> )</ins>** |
|
732 |
+ |
|
733 |
+ To save your edits to a file, press `C-x` `C-s`. If you have been editing in the **scratch** buffer, "File to save in: ~/" is displayed on the echo line. Please specify a file name and save the file. |
|
734 |
+ |
|
735 |
+**<ins>Erase Edit Buffer</ins>** |
|
736 |
+ |
|
737 |
+To erase a edit buffer, press `C-x` `k`. |
|
738 |
+"Kill buffer: (default test.txt)" is displayed on an echo line. Then press Enter key. |
|
739 |
+If the contents of the buffer have not been changed, it will be erased without message. If the contents of the buffer have been changed, the message "Buffer test.txt modified; kill anyway?(yes or no)" is displayed. Enter "yes" to invalidate the change and erase, or enter "no" and Enter key to cancel the erasure. |
|
740 |
+ |
|
741 |
+ |
|
742 |
+### Exit Emacs{#emacs_end} |
|
743 |
+ |
|
744 |
+To exit **Emacs**, press `C-x` `C-c`. |
|
745 |
+If there is an unsaved edit buffer, the following message appears on the echo line |
|
746 |
+(The file name is an example.) |
|
747 |
+ |
|
748 |
+```nohighlight |
|
749 |
+Save file /home/a/b59999/test.txt? (y, n, !, ., q, C-r or C-h) |
|
750 |
+``` |
|
751 |
+Enter "y" to save the file and exit, or enter "n" to exit without saving and press Enter. |
|
752 |
+If you enter "n", a confirmation message will appear on the echo line. |
|
753 |
+Enter "yes" if you really want to exit, or enter "no" if you want to cancel the exit. |
|
754 |
+ |
|
755 |
+ |
|
756 |
+```nohighlight |
|
757 |
+Modified buffers exist; exit anyway? (yes or no) |
|
758 |
+``` |
|
759 |
+ |
|
760 |
+ |
|
761 |
+ |
|
762 |
+### To Master Emacs{#emacs_maseer} |
|
763 |
+ |
|
764 |
+**Emacs** provides tutorials. To start tutorials, press `M-?` `t`. Please try it if you want to master **Emacs** quickly. In the tutorial, you will learn a lot of other functions that are not introduced here. |
|
765 |
+The tutorial uses a buffer, so erase it by `C-x` `k` when you finish the tutorial. |
|
766 |
+ |
743 | 767 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,18 @@ |
1 |
+--- |
|
2 |
+title: Others |
|
3 |
+taxonomy: |
|
4 |
+ category: |
|
5 |
+ - docs |
|
6 |
+content: |
|
7 |
+ items: '@self.children' |
|
8 |
+process: |
|
9 |
+ markdown: true |
|
10 |
+ twig: true |
|
11 |
+twig_first: true |
|
12 |
+--- |
|
13 |
+ |
|
14 |
+This chapter contains various information on the use of the system. |
|
15 |
+ |
|
16 |
+{% for p in page.collection %} |
|
17 |
+* [{{ p.title|e }}](https://web.kudpc.kyoto-u.ac.jp{{p.link}}) |
|
18 |
+{% endfor %} |