-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummit2020_demo_001.txt
187 lines (112 loc) · 4.71 KB
/
summit2020_demo_001.txt
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#######################################################################################
# PASS Virtual Summit 2020 - SQL Server on Linux from A to Z (Randolph West) #
# Pre-conference session (2020-11-10) #
#######################################################################################
# The scripts in this document are procured from several sources, including Microsoft #
# Docs, Wikipedia, genuinecoder.com, linuxhint.com, howtogeek.com, linux.org, #
# ss64.com, and tecmint.com. #
# No copyright is claimed or intended from these code samples #
#######################################################################################
#######################################################################################
### Part 1: Connecting to your Linux server
#######################################################################################
# Connect to your server using SSH (secure shell)
#######################################################################################
### Part 2: Who / where / what?
#######################################################################################
# Who am I? What is my username?
whoami
# What version of Ubuntu Server is this?
lsb_release -a # this does not work on other distributions
# See who else is logged into the computer:
who
# Where am I? Print the working directory (a.k.a. present working directory):
pwd
# List the contents of your home directory:
ls
ls -l # long listing (detailed view)
ls -la # all files (includes hidden)
ls -lh # human readable file sizes
ls -lS # ordered by size
ls -F # shows a trailing slash on directories
ls -R # recursive mode
ls -r # reverse output order
ls -t # ordered by date
# Try some combinations!
ls -alF
ls -ltr
# Try this on its own:
ll
# What else does -F show?
ls -alF
### MORE HERE: https://ss64.com/bash/ls.html
#######################################################################################
### Part 3: File and folder manipulation
#######################################################################################
# Make a new directory in your home directory:
mkdir Test
# Make a lower-case directory with the same name:
mkdir test
# Do a directory listing and see the two directories with the same name:
ls -la
# Create an empty file:
touch newfile.txt
# See the file:
ls -la
# Move the file to the test directory:
mv newfile.txt test
# Go into the test directory and see the file:
cd test
ls -la
# Copy the file and give it a new name:
cp newfile.txt filecopy.txt
# Move the copied file to the Test directory (note the upper-case T):
mv filecopy.txt ../Test
# Copy the file again and give it a different name:
cp newfile.txt to_be_deleted.txt
# Delete (remove) the newly-created file:
rm to_be_deleted.txt
# Delete (remove) the Test folder (note the upper-case T):
cd .. # go up one directory
pwd # confirm where you expect to be
rmdir Test # remove the Test folder. What happens?
### If there is an error message, what does it mean?
# Try using rm (remove) instead:
pwd # make sure you're in the right place
rmdir Test # remove the Test directory
### If there is an error message, what does it mean?
# Try removing a directory with recursion (the directory and everything in it):
pwd # make sure you're in the right place
rm -r Test # force-remove the Test directory
ls -la # confirm that it has been deleted
#######################################################################################
### Part 4: Viewing files
#######################################################################################
# Add some random text from the built-in dictionary to a file:
cd ~ # change to the home folder
ls -la
cat /usr/share/dict/words | sort -R | head -1024 > test/newfile.txt # note the test directory
# View the contents of the file:
cd ~/test
cat newfile.txt
# Use the more and less commands to interrogate the file:
more newfile.txt
less newfile.txt
### Use the up and down arrows in each example and see what happens
### You will use the q key to quit from the viewer
# Look at the first 10 lines:
head newfile.txt
# Look at the last 10 lines:
tail newfile.txt
# Use the -n switch to change the number of lines:
tail -15 newfile.txt
### Let's try some pipeline actions
# Get the data from line 20 of the file and pipe it to less:
tail +20 newfile.txt | less
# Show the last 50 bytes of the file:
tail -c 50 newfile.txt
# Show the oldest two entries in a directory listing:
ls -tl ~ | tail -2
# Show only the lines in the containing the letter "s":
tail newfile.txt | grep s