Linux numbers/figures before the user's and group's names - linux

After thorough research online, I've struggled to figure out what the NUMBERS BEFORE USER's NAME on linux mean and how we can change it ? This is for classroom homework purpose.
I'll explain myself clearer with the following example. After a ls-l, I got this:
" drwxr-xr-x 2 John Family 2048 June 14 "
Here's my question Does anybody know what does the "2" before John mean ? Can we change that number with a specific command line ? Maybe chmod ?
Please note, I'm very new to developing as a general (just have a few basics in C language) and stackoverflow so I may be very clumsy in my approach.
Thanks guys in advance for those who would be willing to shed some light on the darkness of my novice-ness ahah

You can find more information about ls from the man page that you can read at man ls. In particular, look for the section that will be labelled The Long Format, which goes into much detail. On my system (OS X 10.10) it reads as follows:
If the -l option is given, the following information is displayed for
each file: file mode, number of links, owner name, group name, number
of bytes in the file, abbreviated month, day-of-month file was last
modified, hour file last modified, minute file last modified, and the
pathname.
In general, you find details about Unix commands with the man command.

I found the answer thanks to you ! the number correponds to the number of links (hardlinks or symbolic links) and this number can be influenced by the command "ln" or (for a symbolic link) "ln -s". Thanks again vielmetti – Zel just now edit

Related

Locating files starting with a string for my hw

I have a conundrum and I am not necessarily trying to cheat or anything I am just simply stuck. I am trying to complete an assignment for my intro to Linux class and I was hoping someone would be able to help me find the right solution. I have to:
In the same directory (where the last file was found) list all files
starting with "host" --
Use the long listing format Use a command to
find the file that shows the name of your computer
now the directory in question is /etc and I have tried several commands to no avail for both of these but especially the first one. I have tried find and locate and even attempted a grep and it just is not working as intended. I can't get files that start with "host" at most I keep getting a list of permission denied or files that end in .host and so I am not sure what I am doing wrong but I really need help so I can turn in my assignment. You don't have to tell me what the exact command should be I am just looking for some guidance again I am not trying to cheat just need help to figure it out.
and welcome to Stack Overflow! Here are some pointers.
See globbing in Linux and the * symbol.
"long listing" is an option for ls command, see ls --help. The name of your computer (or, more accurately, the name of your host) is a file in /etc/. You should see it when doing #1.

Counting up within text program?

I am editing app code to increase floors in tiny tower.
My dilemma is I need to have a large amount of text with a single number increasing by one after some constant text repeating over and over.
Sorry, I'm not good at describing what I need so I'll show y'all an example of what I need.
[Fs]**X**[Fs][Ff]58[Ff][Fl]1[Fl][Fod]0[Fod][Fsbt]1[Fsbt][Fsi]-1[Fsi][Fst]-1[Fst][Fstk]0,0,0[Fstk][Flst]0,0,0[Flst][Fn][Fn]|
I need this line of text repeating over and over again with the exception of the bolded X increasing by 1 every time the text repeats.
Such as
[Fs]**1**[Fs][Ff]58[Ff][Fl]1[Fl][Fod]0[Fod][Fsbt]1[Fsbt][Fsi]-1[Fsi][Fst]-1[Fst][Fstk]0,0,0[Fstk][Flst]0,0,0[Flst][Fn][Fn]|[Fs]**2**[Fs][Ff]58[Ff][Fl]1[Fl][Fod]0[Fod][Fsbt]1[Fsbt][Fsi]-1[Fsi][Fst]-1[Fst][Fstk]0,0,0[Fstk][Flst]0,0,0[Flst][Fn][Fn]|[Fs]**3**[Fs][Ff]58[Ff][Fl]1[Fl][Fod]0[Fod][Fsbt]1[Fsbt][Fsi]-1[Fsi][Fst]-1[Fst][Fstk]0,0,0[Fstk][Flst]0,0,0[Flst][Fn][Fn]|[Fs]**4**[Fs][Ff]58[Ff][Fl]1[Fl][Fod]0[Fod][Fsbt]1[Fsbt][Fsi]-1[Fsi][Fst]-1[Fst][Fstk]0,0,0[Fstk][Flst]0,0,0[Flst][Fn][Fn]| ETC...
I have manually written this code out to 5000 lines and I can't take it anymore. I don't know how many I need but if someone could give me either straight up the text that I need or some way for me to do it myself that would be amazing.
I need it to count up to at least 10k and id say 100k at the max.
Thanks for your help and please ask any questions if you need them answered to further help me.
In bash you could do
printf '[Fs]%s[Fs][Ff]58[Ff][Fl]1[Fl][Fod]0[Fod][Fsbt]1[Fsbt][Fsi]-1[Fsi][Fst]-1[Fst][Fstk]0,0,0[Fstk][Flst]0,0,0[Flst][Fn][Fn]|\n' {1..100000} > /path/to/the/outputfile
To create a file outputfile with the first 100k lines.
On Linux or Mac open a terminal (on Windows you can use WSL, gitbash, or cygwin), type bash, press enter, type the command from above, press enter again.

Finding 2 numerical strings on same line

I am new to Notepad++ and have ben researching how to do this, but it seems each answer I try to mimic doesn't work correctly.
Here is the scenario:
I have 2 text files, each with ATM transactions such as time of transaction (In military time, such as 18:09) and transaction amount (Displayed as 43.00)
I need to find a way to search the document so that it only returns matches where both the time and amount are there, and on the same line of the document.
Example would be, I need to find on this huge text file where both 43.00 and 18:09 appear on the same line, allowing my to verify the transaction was valid.
Any ideas on how to do this? I am using the latest Notepad++6.8 and have downloaded the compare plugin.
Thank you and I will begin researching how the coding works in notepad++ in the meantime, as I am not an experienced programmer (Just had 1 college course in C++ which I loved but eh)
Cheers!
Ctrl-F, Select "Regular expression" as Search mode and then write:
8:09.*43.00
Ctrl F, search for 43.00 or 18:09.

UNIX man command to find list of man sections

I'm working on a lab that is supposed to help us better navigate the command line on a Linux system, but I'm getting stuck on man pages.
We are supposed to use the man command to find a list of the man page sections, adn I can't seem to figure out how to do this. I've tried entering
man man
but that doesn't give me any information on the individual sections. I've also tried looking on Google to find what command I should use, but no luck there either.
Can anybody point me in the right direction?
apropos -r '.*'
This will list all manual pages. A script to chop this up into lists by section is a follow-up homework assignment.

Linux command line : edit hacked index files [duplicate]

This question already has an answer here:
Hacked Site - SSH to remove a large body of javascript from 200+ files [closed]
(1 answer)
Closed 2 years ago.
I'm unfortunately once more dealing with a hacked site on a Linux Plesk server. While the issue is fixed with FTP access changed (it got down to the famous Filezilla FTP codes hack on a PC) I'd appreciate to know how to edit files as it may take over an hour to restore the site to the most recent backup we have, and I'd be glad to have it back online faster.
The hack is rather simple: a javascript code was inserted in many index* (only index.php it seems) files in the site.
I'm looking for a way to mass-edit the hacked files, knowing that even though the target javascript code is the same, it is called from a number of probably also hacked sites. So while my legitimate index file used to start with
<?php
it now starts like
<script type="text/javascript" src="http://(RANDOMDOMAINHERE)/facebook.php"></script><?php
As that chain contains a variable, could you help me find a sure-fire method to edit all the changed Index files (about 80 found) ?
I have used a SED replace before but this time part of the chain to replace varies, so could I use a wildcard ?
Best regards, thanks for shedding light !
find -name 'index.php' -print0 |
xargs -0 sed -i '1s#^<script type="text/javascript" src="http://.*\?/facebook.php"></script>##g'
Should do wonders
the sed command:
1 (match in first line)
s#pattern#replacement#g (replace pattern by replacement, not that the latter is empty)
^ must match at start of line
.*\? accept arbitrary length of sequence of characters; however if more than one a match for the whole pattern could be made, only match the shortest possible variant of it
Cheers
I sincerely hope your not actually adminning a production domain. You should inform your users, get the problem fixed, offer the users to go back to a recent backup that hasn't got the problem.
There is no telling what else has been tampered with.
I'm glad my VPS is somewhere else!
I would fix the Cross side scripting exploit before this problem is addressed or it will all be in vain. When thats done a simple search and replace of blocks of script that contain a common string should be sufficient.

Resources